This implements the last remaining link functions using the same logic as WASI. In doing so, this changes the signature for FS.ReadLink to be more similar to the rest of the functions. Particularly, it stops reading the result into a buffer. After this, the only syscalls left to implement in gojs are chown. Signed-off-by: Adrian Cole <adrian@tetrate.io>
18 lines
418 B
Go
18 lines
418 B
Go
package platform
|
|
|
|
import "strings"
|
|
|
|
// ToPosixPath returns the input, converting any backslashes to forward ones.
|
|
func ToPosixPath(in string) string {
|
|
// strings.Map only allocates on change, which is good enough especially as
|
|
// path.Join uses forward slash even on windows.
|
|
return strings.Map(windowsToPosixSeparator, in)
|
|
}
|
|
|
|
func windowsToPosixSeparator(r rune) rune {
|
|
if r == '\\' {
|
|
return '/'
|
|
}
|
|
return r
|
|
}
|