MCPcopy Index your code
hub / github.com/pyodide/pyodide / windowsPathToUnix

Function windowsPathToUnix

src/templates/python_cli_entry.mjs:43–54  ·  view source on GitHub ↗

* Convert a Windows absolute path to a Unix-style path. * Strips the drive letter (e.g., "C:") and converts backslashes to forward slashes. * * @example * windowsPathToUnix("C:\\Users\\siha\\file.txt") // returns "/Users/siha/file.txt" * windowsPathToUnix("D:\\projects\\myapp") // returns "/pro

(path)

Source from the content-addressed store, hash-verified

41 * windowsPathToUnix("D:\\projects\\myapp") // returns "/projects/myapp"
42 */
43function windowsPathToUnix(path) {
44 if (process.platform === "win32") {
45 // Remove drive letter (e.g., "C:" or "D:")
46 let unixPath = path.replace(/^[A-Za-z]:/, "");
47
48 // Replace all backslashes with forward slashes
49 unixPath = unixPath.replace(/\\/g, "/");
50
51 return unixPath;
52 }
53 return path;
54}
55
56/**
57 * Escape backslashes in a Windows path for use in Python strings.

Callers 2

calculateSysPathFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…