is there an api to store and load the entire imfs to and from persistent storage as a single file?
weihsiu opened this issue · 2 comments
weihsiu commented
i looked around and couldn't find an api that would store and load the entire imfs to and from persistent storage. it would be a tremendous feature to be able to persist the file system and load it back some time later.
cgdecker commented
You should be able to do that using the standard file APIs. Here's what I'd suggest:
- Create a .zip file on the file system you want to persist to.
- Open that zip file as a FileSystem using FileSystems.newFileSystem(Path, ClassLoader).
- Recursively copy the files in the root of your in memory file system to the zip file system's root.
- Close the zip FileSystem.
cgdecker commented
(This isn't something I'm likely to add to Jimfs itself as it basically boils down to a method to create a zip file from the contents of a directory.)