File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ export abstract class Fd {
105105 path_readlink ( path : string ) : { ret : number ; data : string | null } {
106106 return { ret : wasi . ERRNO_NOTSUP , data : null } ;
107107 }
108+ path_symlink ( old_path : string , new_path : string ) : number {
109+ return wasi . ERRNO_NOTSUP ;
110+ }
108111 path_remove_directory ( path : string ) : number {
109112 return wasi . ERRNO_NOTSUP ;
110113 }
Original file line number Diff line number Diff line change @@ -415,6 +415,34 @@ export class OpenDirectory extends Fd {
415415 return wasi . ERRNO_SUCCESS ;
416416 }
417417
418+ path_symlink ( old_path_str : string , new_path_str : string ) : number {
419+ const { ret : new_ret , path : new_path } = Path . from ( new_path_str ) ;
420+ if ( new_path == null ) {
421+ return new_ret ;
422+ }
423+
424+ const {
425+ ret : parent_ret ,
426+ parent_entry,
427+ filename,
428+ } = this . dir . get_parent_dir_and_entry_for_path ( new_path , true ) ;
429+ if ( parent_entry == null || filename == null ) {
430+ return parent_ret ;
431+ }
432+
433+ const { ret : old_ret , path : old_path } = Path . from ( old_path_str ) ;
434+ if ( old_path == null ) {
435+ return old_ret ;
436+ }
437+
438+ const { ret : entry_ret , entry } = parent_entry . get_entry_for_path ( old_path ) ;
439+ if ( entry == null ) {
440+ return entry_ret ;
441+ }
442+
443+ return this . path_link ( new_path_str , entry , true ) ;
444+ }
445+
418446 path_unlink ( path_str : string ) : { ret : number ; inode_obj : InodeMem | null } {
419447 const { ret : path_ret , path } = Path . from ( path_str ) ;
420448 if ( path == null ) {
Original file line number Diff line number Diff line change @@ -813,15 +813,13 @@ export default class WASI {
813813 ) : number {
814814 const buffer8 = new Uint8Array ( self . inst . exports . memory . buffer ) ;
815815 if ( self . fds [ fd ] != undefined ) {
816- // eslint-disable-next-line @typescript-eslint/no-unused-vars
817816 const old_path = new TextDecoder ( "utf-8" ) . decode (
818817 buffer8 . slice ( old_path_ptr , old_path_ptr + old_path_len ) ,
819818 ) ;
820- // eslint-disable-next-line @typescript-eslint/no-unused-vars
821819 const new_path = new TextDecoder ( "utf-8" ) . decode (
822820 buffer8 . slice ( new_path_ptr , new_path_ptr + new_path_len ) ,
823821 ) ;
824- return wasi . ERRNO_NOTSUP ;
822+ return self . fds [ fd ] . path_symlink ( old_path , new_path ) ;
825823 } else {
826824 return wasi . ERRNO_BADF ;
827825 }
You can’t perform that action at this time.
0 commit comments