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

Function dirsToMount

src/templates/python_cli_entry.mjs:12–33  ·  view source on GitHub ↗

* Determine which native top level directories to mount into the Emscripten * file system. * * This is a bit brittle, if the machine has a top level directory with certain * names it is possible this could break. The most surprising one here is tmp, I * am not sure why but if we link tmp then t

()

Source from the content-addressed store, hash-verified

10 * am not sure why but if we link tmp then the process silently fails.
11 */
12function dirsToMount() {
13 const filteredDirs = new Set([
14 // Unix
15 "dev",
16 "lib",
17 "proc",
18 ]);
19
20 return readdirSync("/")
21 .filter((dir) => !filteredDirs.has(dir))
22 .filter((dir) => !dir.startsWith("$")) // System directories in Windows, such as $Recycle.Bin
23 .filter((dir) => {
24 // Use stat to confirm this entry is a directory.
25 try {
26 const st = statSync("/" + dir);
27 return st.isDirectory();
28 } catch (e) {
29 return false;
30 }
31 })
32 .map((dir) => "/" + dir);
33}
34
35/**
36 * Convert a Windows absolute path to a Unix-style path.

Callers 1

fsInitFunction · 0.85

Calls 3

mapMethod · 0.80
filterMethod · 0.80
hasMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…