mirror of
https://github.com/boostorg/filesystem.git
synced 2026-01-19 04:12:09 +00:00
Implement on top of posix API for emscripten
This commit is contained in:
committed by
Andrey Semashev
parent
1f2e37cae5
commit
ef54f768b8
@@ -38,12 +38,16 @@
|
||||
#endif
|
||||
#include <cerrno>
|
||||
|
||||
#if defined(__wasm) && (defined(EMSCRIPTEN_STANDALONE_WASM) || !defined(__EMSCRIPTEN__))
|
||||
#define BOOST_STANDALONE_WASM 1
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_POSIX_API
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(__wasm)
|
||||
#if defined(BOOST_STANDALONE_WASM)
|
||||
// WASI does not have statfs or statvfs.
|
||||
#elif !defined(__APPLE__) && \
|
||||
(!defined(__OpenBSD__) || BOOST_OS_BSD_OPEN >= BOOST_VERSION_NUMBER(4, 4, 0)) && \
|
||||
@@ -2220,7 +2224,7 @@ bool copy_file(path const& from, path const& to, unsigned int options, error_cod
|
||||
}
|
||||
|
||||
mode_t to_mode = from_mode;
|
||||
#if !defined(__wasm)
|
||||
#if !defined(BOOST_STANDALONE_WASM)
|
||||
// Enable writing for the newly created files. Having write permission set is important e.g. for NFS,
|
||||
// which checks the file permission on the server, even if the client's file descriptor supports writing.
|
||||
to_mode |= S_IWUSR;
|
||||
@@ -2339,7 +2343,7 @@ bool copy_file(path const& from, path const& to, unsigned int options, error_cod
|
||||
if (BOOST_UNLIKELY(err != 0))
|
||||
goto fail; // err already contains the error code
|
||||
|
||||
#if !defined(__wasm)
|
||||
#if !defined(BOOST_STANDALONE_WASM)
|
||||
// If we created a new file with an explicitly added S_IWUSR permission,
|
||||
// we may need to update its mode bits to match the source file.
|
||||
if (to_mode != from_mode)
|
||||
@@ -2775,7 +2779,7 @@ void create_symlink(path const& to, path const& from, error_code* ec)
|
||||
BOOST_FILESYSTEM_DECL
|
||||
path current_path(error_code* ec)
|
||||
{
|
||||
#if defined(UNDER_CE) || defined(__wasm)
|
||||
#if defined(UNDER_CE) || defined(BOOST_STANDALONE_WASM)
|
||||
// Windows CE has no current directory, so everything's relative to the root of the directory tree.
|
||||
// WASI also does not support current path.
|
||||
emit_error(BOOST_ERROR_NOT_SUPPORTED, ec, "boost::filesystem::current_path");
|
||||
@@ -2845,7 +2849,7 @@ path current_path(error_code* ec)
|
||||
BOOST_FILESYSTEM_DECL
|
||||
void current_path(path const& p, system::error_code* ec)
|
||||
{
|
||||
#if defined(UNDER_CE) || defined(__wasm)
|
||||
#if defined(UNDER_CE) || defined(BOOST_STANDALONE_WASM)
|
||||
emit_error(BOOST_ERROR_NOT_SUPPORTED, p, ec, "boost::filesystem::current_path");
|
||||
#else
|
||||
error(!BOOST_SET_CURRENT_DIRECTORY(p.c_str()) ? BOOST_ERRNO : 0, p, ec, "boost::filesystem::current_path");
|
||||
@@ -3349,7 +3353,7 @@ void permissions(path const& p, perms prms, system::error_code* ec)
|
||||
if ((prms & add_perms) && (prms & remove_perms)) // precondition failed
|
||||
return;
|
||||
|
||||
#if defined(__wasm)
|
||||
#if defined(BOOST_STANDALONE_WASM)
|
||||
emit_error(BOOST_ERROR_NOT_SUPPORTED, p, ec, "boost::filesystem::permissions");
|
||||
#elif defined(BOOST_POSIX_API)
|
||||
error_code local_ec;
|
||||
@@ -3613,7 +3617,7 @@ space_info space(path const& p, error_code* ec)
|
||||
if (ec)
|
||||
ec->clear();
|
||||
|
||||
#if defined(__wasm)
|
||||
#if defined(BOOST_STANDALONE_WASM)
|
||||
|
||||
emit_error(BOOST_ERROR_NOT_SUPPORTED, p, ec, "boost::filesystem::space");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user