@@ -814,17 +814,15 @@ export function useMemoryFS(
814
814
opened_fd : number
815
815
) => {
816
816
const view = memoryView ( ) ;
817
- let path = "" ;
818
- for ( let i = 0 ; i < pathLen ; i ++ ) {
819
- path += String . fromCharCode ( view . getUint8 ( pathPtr + i ) ) ;
820
- }
821
817
822
818
if ( dirfd < 3 ) return WASIAbi . WASI_ERRNO_NOTDIR ;
823
819
824
820
const dirEntry = getFileFromFD ( dirfd ) ;
825
821
if ( ! dirEntry || dirEntry . node . type !== "dir" )
826
822
return WASIAbi . WASI_ERRNO_NOTDIR ;
827
823
824
+ const path = abi . readString ( view , pathPtr , pathLen ) ;
825
+
828
826
const guestPath =
829
827
( dirEntry . path . endsWith ( "/" ) ? dirEntry . path : dirEntry . path + "/" ) +
830
828
path ;
@@ -876,17 +874,15 @@ export function useMemoryFS(
876
874
opened_fd : number
877
875
) => {
878
876
const view = memoryView ( ) ;
879
- let path = "" ;
880
- for ( let i = 0 ; i < pathLen ; i ++ ) {
881
- path += String . fromCharCode ( view . getUint8 ( pathPtr + i ) ) ;
882
- }
883
877
884
878
if ( dirfd < 3 ) return WASIAbi . WASI_ERRNO_NOTDIR ;
885
879
886
880
const dirEntry = getFileFromFD ( dirfd ) ;
887
881
if ( ! dirEntry || dirEntry . node . type !== "dir" )
888
882
return WASIAbi . WASI_ERRNO_NOTDIR ;
889
883
884
+ const path = abi . readString ( view , pathPtr , pathLen ) ;
885
+
890
886
const guestPath =
891
887
( dirEntry . path . endsWith ( "/" ) ? dirEntry . path : dirEntry . path + "/" ) +
892
888
path ;
@@ -938,19 +934,15 @@ export function useMemoryFS(
938
934
) => {
939
935
const view = memoryView ( ) ;
940
936
941
- // Read the relative path from WASM memory.
942
- let guestRelPath = "" ;
943
- for ( let i = 0 ; i < pathLen ; i ++ ) {
944
- guestRelPath += String . fromCharCode ( view . getUint8 ( pathPtr + i ) ) ;
945
- }
946
-
947
937
// Get the base FD entry; it must be a directory.
948
938
const file = getFileFromFD ( fd ) ;
949
939
if ( ! file ) return WASIAbi . WASI_ERRNO_BADF ;
950
940
if ( file . node . type !== "dir" ) {
951
941
return WASIAbi . WASI_ERRNO_NOTDIR ;
952
942
}
953
943
944
+ const guestRelPath = abi . readString ( view , pathPtr , pathLen ) ;
945
+
954
946
// Compute the full guest path.
955
947
const basePath = file . path ;
956
948
const fullGuestPath = basePath . endsWith ( "/" )
0 commit comments