* 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
()
| 10 | * am not sure why but if we link tmp then the process silently fails. |
| 11 | */ |
| 12 | function 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. |