github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/sysfs/dirfs_supported.go (about) 1 //go:build !tinygo 2 3 package sysfs 4 5 import ( 6 "io/fs" 7 "os" 8 9 experimentalsys "github.com/tetratelabs/wazero/experimental/sys" 10 ) 11 12 // Link implements the same method as documented on sys.FS 13 func (d *dirFS) Link(oldName, newName string) experimentalsys.Errno { 14 err := os.Link(d.join(oldName), d.join(newName)) 15 return experimentalsys.UnwrapOSError(err) 16 } 17 18 // Unlink implements the same method as documented on sys.FS 19 func (d *dirFS) Unlink(path string) (err experimentalsys.Errno) { 20 return unlink(d.join(path)) 21 } 22 23 // Rename implements the same method as documented on sys.FS 24 func (d *dirFS) Rename(from, to string) experimentalsys.Errno { 25 from, to = d.join(from), d.join(to) 26 return rename(from, to) 27 } 28 29 // Chmod implements the same method as documented on sys.FS 30 func (d *dirFS) Chmod(path string, perm fs.FileMode) experimentalsys.Errno { 31 err := os.Chmod(d.join(path), perm) 32 return experimentalsys.UnwrapOSError(err) 33 } 34 35 // Symlink implements the same method as documented on sys.FS 36 func (d *dirFS) Symlink(oldName, link string) experimentalsys.Errno { 37 // Note: do not resolve `oldName` relative to this dirFS. The link result is always resolved 38 // when dereference the `link` on its usage (e.g. readlink, read, etc). 39 // https://github.com/bytecodealliance/cap-std/blob/v1.0.4/cap-std/src/fs/dir.rs#L404-L409 40 err := os.Symlink(oldName, d.join(link)) 41 return experimentalsys.UnwrapOSError(err) 42 }