Closed Atybot closed 1 year ago
@james-pre Thanks for maintaining this great project! Following up the question, it seems the fs.cp
is not in the code. I was wondering where to find it? Or currently I need to write my own traversal function for it? Thanks.
@h365chen
That is correct. You would have to use fs.rename
/fs.renameSync
instead of copying until I get around to adding cp
, rm
, and mv
.
I'm currently updating the tests and working on getting my changes put out to NPM. If my improvements are only on the GitHub repo it will not help the majority of BFS users.
@james-pre
fs.rename
/ fs.renameSync
seems not able to move dir from ZipFS. Does making it OverlayFS help?
Currently, I have a MountableFS where /zip
is ZipFS and /mem
is InMemory, but I don’t know how to make /zip
as an OverlayFS.
I would like to copy /zip/*
to /mem/
@h365chen Looking through the source, it does not appear there is a way to copy files.
The best way I can think of to fix this (temporarily) is like so:
const overlayFS = await BrowserFS.FileSystem.OverlayFS.CreateAsync({ readable: zipFS, writable: memFS });
mountableFS.mount('/mnt/zip', overlayFS);
This assumes you are working with ES6+. If not, you must deal with the callbacks or .then
.
@james-pre Thanks! I was using npm install browserfs@beta
so I guess there is no CreateAsync
there. I'll see if I can find a workaround. Thanks!
@h365chen You can use it with the regular Create
method:
BrowserFS.FileSystem.OverlayFS.Create({ readable: zipFS, writable: memFS }, (e, overlayFS) => {
if(e) {
throw e;
}
mountableFS.mount('/mnt/zip', overlayFS);
});
@Atybot Currently you would create an LocalStorageFS and ZipFS and mount them to a MountableFilesystem (e.g.
/localstorage
and/zip
). then you could dofs.cp('/zip', '/localstorage', { recursive: true });
In the future, we could have a separate function for unpacking zip files (e.g.
BrowserFS.BFSUtils.ConvertZipToDirectory
)