|
38 | 38 | #endif
|
39 | 39 | #include <cerrno>
|
40 | 40 |
|
41 |
| -// Use WASI when not building with emscripten or when BOOST_FILESYSTEM_DISABLE_EMSCRIPTEN_WASI is not set |
42 |
| -#if defined(__wasm) && (!defined(__EMSCRIPTEN__) || !defined(BOOST_FILESYSTEM_DISABLE_EMSCRIPTEN_WASI)) |
43 |
| -#define BOOST_FILESYSTEM_STANDALONE_WASM |
| 41 | +// Default to POSIX under Emscripten |
| 42 | +// If BOOST_FILESYSTEM_EMSCRIPTEN_USE_WASI is set, use WASI instead |
| 43 | +#if defined(__wasm) && (!defined(__EMSCRIPTEN__) || defined(BOOST_FILESYSTEM_EMSCRIPTEN_USE_WASI)) |
| 44 | +#define BOOST_FILESYSTEM_USE_WASI |
44 | 45 | #endif
|
45 | 46 |
|
46 | 47 | #ifdef BOOST_POSIX_API
|
47 | 48 |
|
48 | 49 | #include <sys/types.h>
|
49 | 50 | #include <sys/stat.h>
|
50 | 51 |
|
51 |
| -#if defined(BOOST_FILESYSTEM_STANDALONE_WASM) |
| 52 | +#if defined(BOOST_FILESYSTEM_USE_WASI) |
52 | 53 | // WASI does not have statfs or statvfs.
|
53 | 54 | #elif !defined(__APPLE__) && \
|
54 | 55 | (!defined(__OpenBSD__) || BOOST_OS_BSD_OPEN >= BOOST_VERSION_NUMBER(4, 4, 0)) && \
|
@@ -2225,7 +2226,7 @@ bool copy_file(path const& from, path const& to, unsigned int options, error_cod
|
2225 | 2226 | }
|
2226 | 2227 |
|
2227 | 2228 | mode_t to_mode = from_mode;
|
2228 |
| -#if !defined(BOOST_FILESYSTEM_STANDALONE_WASM) |
| 2229 | +#if !defined(BOOST_FILESYSTEM_USE_WASI) |
2229 | 2230 | // Enable writing for the newly created files. Having write permission set is important e.g. for NFS,
|
2230 | 2231 | // which checks the file permission on the server, even if the client's file descriptor supports writing.
|
2231 | 2232 | to_mode |= S_IWUSR;
|
@@ -2344,7 +2345,7 @@ bool copy_file(path const& from, path const& to, unsigned int options, error_cod
|
2344 | 2345 | if (BOOST_UNLIKELY(err != 0))
|
2345 | 2346 | goto fail; // err already contains the error code
|
2346 | 2347 |
|
2347 |
| -#if !defined(BOOST_FILESYSTEM_STANDALONE_WASM) |
| 2348 | +#if !defined(BOOST_FILESYSTEM_USE_WASI) |
2348 | 2349 | // If we created a new file with an explicitly added S_IWUSR permission,
|
2349 | 2350 | // we may need to update its mode bits to match the source file.
|
2350 | 2351 | if (to_mode != from_mode)
|
@@ -2780,7 +2781,7 @@ void create_symlink(path const& to, path const& from, error_code* ec)
|
2780 | 2781 | BOOST_FILESYSTEM_DECL
|
2781 | 2782 | path current_path(error_code* ec)
|
2782 | 2783 | {
|
2783 |
| -#if defined(UNDER_CE) || defined(BOOST_FILESYSTEM_STANDALONE_WASM) |
| 2784 | +#if defined(UNDER_CE) || defined(BOOST_FILESYSTEM_USE_WASI) |
2784 | 2785 | // Windows CE has no current directory, so everything's relative to the root of the directory tree.
|
2785 | 2786 | // WASI also does not support current path.
|
2786 | 2787 | emit_error(BOOST_ERROR_NOT_SUPPORTED, ec, "boost::filesystem::current_path");
|
@@ -2850,7 +2851,7 @@ path current_path(error_code* ec)
|
2850 | 2851 | BOOST_FILESYSTEM_DECL
|
2851 | 2852 | void current_path(path const& p, system::error_code* ec)
|
2852 | 2853 | {
|
2853 |
| -#if defined(UNDER_CE) || defined(BOOST_FILESYSTEM_STANDALONE_WASM) |
| 2854 | +#if defined(UNDER_CE) || defined(BOOST_FILESYSTEM_USE_WASI) |
2854 | 2855 | emit_error(BOOST_ERROR_NOT_SUPPORTED, p, ec, "boost::filesystem::current_path");
|
2855 | 2856 | #else
|
2856 | 2857 | error(!BOOST_SET_CURRENT_DIRECTORY(p.c_str()) ? BOOST_ERRNO : 0, p, ec, "boost::filesystem::current_path");
|
@@ -3354,7 +3355,7 @@ void permissions(path const& p, perms prms, system::error_code* ec)
|
3354 | 3355 | if ((prms & add_perms) && (prms & remove_perms)) // precondition failed
|
3355 | 3356 | return;
|
3356 | 3357 |
|
3357 |
| -#if defined(BOOST_FILESYSTEM_STANDALONE_WASM) |
| 3358 | +#if defined(BOOST_FILESYSTEM_USE_WASI) |
3358 | 3359 | emit_error(BOOST_ERROR_NOT_SUPPORTED, p, ec, "boost::filesystem::permissions");
|
3359 | 3360 | #elif defined(BOOST_POSIX_API)
|
3360 | 3361 | error_code local_ec;
|
@@ -3618,7 +3619,7 @@ space_info space(path const& p, error_code* ec)
|
3618 | 3619 | if (ec)
|
3619 | 3620 | ec->clear();
|
3620 | 3621 |
|
3621 |
| -#if defined(BOOST_FILESYSTEM_STANDALONE_WASM) |
| 3622 | +#if defined(BOOST_FILESYSTEM_USE_WASI) |
3622 | 3623 |
|
3623 | 3624 | emit_error(BOOST_ERROR_NOT_SUPPORTED, p, ec, "boost::filesystem::space");
|
3624 | 3625 |
|
|
0 commit comments