Skip to content

Commit

Permalink
Ensure POSIX path normalizing behavior under NODERAWFS
Browse files Browse the repository at this point in the history
Avoids mangling `C:/tmp` to `C:\tmp`. Should be safe, the underlying
Windows API can accept either the backslash or slash to separate
directory and file components of a path.

See: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file

Ensures `NODERAWFS` compatibility on Windows that was regressed since
emscripten-core#18163.
  • Loading branch information
kleisauke committed Aug 14, 2024
1 parent cd097fb commit 30def57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/library_nodepath.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
addToLibrary({
$PATH: {
isAbs: (path) => nodePath['isAbsolute'](path),
normalize: (path) => nodePath['normalize'](path),
normalize: (path) => nodePath['posix']['normalize'](path),
dirname: (path) => nodePath['dirname'](path),
basename: (path) => nodePath['basename'](path),
join: (...args) => nodePath['join'](...args),
join2: (l, r) => nodePath['join'](l, r),
join: (...args) => nodePath['posix']['join'](...args),
join2: (l, r) => nodePath['posix']['join'](l, r),
},
// The FS-using parts are split out into a separate object, so simple path
// usage does not require the FS.
Expand Down
1 change: 1 addition & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -9640,6 +9640,7 @@ def test_toolchain_profiler_stderr(self):
self.assertContained('block "main" took', stderr)

@also_with_wasmfs
@crossplatform
def test_noderawfs(self):
self.run_process([EMXX, test_file('fs/test_fopen_write.cpp'), '-sNODERAWFS'] + self.get_emcc_args())
self.assertContained("read 11 bytes. Result: Hello data!", self.run_js('a.out.js'))
Expand Down

0 comments on commit 30def57

Please sign in to comment.