5 ms·
What's special about node.js here? Does golang, C#, python, ruby, java, etc... have a virtual file system? I get it, I've implemented things for tests, I'm jus
by socalgal2 8mo ago
What's special about node.js here? Does golang, C#, python, ruby, java, etc... have a virtual file system?
I get it, I've implemented things for tests, I'm just wondering if this shouldn't be solved at an OS level.
--- update
Let's put this another way, my code does effectively, child_process.spawn('something-that-reads-and-write-a-file')
now I'm back to the same issue. To test I need a virtual file system. Node providing one won't help.
- sauercrowd 8mo agoGo actually does https://pkg.go.dev/embed https://pkg.go.dev/embed I do think it's more painful to distribute files when you're a distributed as a single binary vs scripts, since the latter has to figure out bundling of files anyway. But still - it does exist
- benatkin 8mo agoEmbed is read-only at runtime. This proposed vfs module for Node.js is a full virtual file system.
- sauercrowd 8mo agotrue
- benatkin 8mo agoIt's cool that it fits into golang's readable file system interface so it can be used polymorphically. I don't know if golang has very complete interfaces for a read and write file system that could be used for a full vfs. If it does, that's nice, and a starting point for a similar vfs! I'm also not sure whether it should go into the standard library or not.
- nine_k 8mo agoZip files are created in such a way that they can be a part of an executable file. (This is how self-extracting archives used to work.) Support for reading zip files is lightweight, and is present almost everywhere. A ZIP fork embedded into the executable should be an obvious read-only VFS implementation. Bring your assets with you, even maybe build them with the standard zip utility. It should take relatively few LOCs, provided that libzip is already linked into the executable anyway.
- paradox460 8mo agoIn the past, I've implemented this in Ruby and elixir on Linux systems using a ramdisk.
- antonvs 8mo agoJava, Haskell, Rust, and several other languages do have solutions for this. Here’s one for Rust: https://docs.rs/vfs/latest/vfs/ https://docs.rs/vfs/latest/vfs/
- Retr0id 8mo agoPython doesn't have a virtual filesystem in general but it is possible to shim the import mechanism.