github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/platform/path_windows.go (about)

     1  package platform
     2  
     3  import "strings"
     4  
     5  // ToPosixPath returns the input, converting any backslashes to forward ones.
     6  func ToPosixPath(in string) string {
     7  	// strings.Map only allocates on change, which is good enough especially as
     8  	// path.Join uses forward slash even on windows.
     9  	return strings.Map(windowsToPosixSeparator, in)
    10  }
    11  
    12  func windowsToPosixSeparator(r rune) rune {
    13  	if r == '\\' {
    14  		return '/'
    15  	}
    16  	return r
    17  }