jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.06k stars 215 forks source link

Reading file in OverlayFS #269

Closed lrusso closed 5 years ago

lrusso commented 5 years ago

Hello, first let me congratulate you for developing BrowserFS, it's great. If you have the time, I was wondering if you could help with something.

In the following link, you can see that a game_data file system is created that starts by reading a zip file and allows to perform any writing in deltaFS.

https://github.com/17192175113/17192175113.github.io_old/blob/97a3ec17228537913b3fa6fa21c15b397bfaf191/loader.js

If I use game_data.fs.readdir I can get the file list (new files and the original files from the zip) from any directory, but game_data.fs.readFile and game_data.fs.readFileSync doesn't seems to work.

My question is, how to read the modified/created/original files from deltaFS and game_data.fs?

Thank you very much for your time and help!

jvilk commented 5 years ago

That loader is invoking internal APIs for BrowserFS file system modules and isn't using the emulated Node FS module (via var fs = BrowserFS.BFSRequire('fs');). Thus, it's doing stuff like manually passing in flags to methods:

https://github.com/17192175113/17192175113.github.io_old/blob/97a3ec17228537913b3fa6fa21c15b397bfaf191/loader.js#L927

The logic is very hairy, so it's hard to follow. Using BrowserFS 2.0's configure logic would be cleaner and make it easier to follow.

game_data.fs.readFile and game_data.fs.readFileSync doesn't seems to work.

What error do you get?

lrusso commented 5 years ago

John, thank you for your answer and attention. I was getting a File Not Found error but it was because I was missing some path references. If this happened to anyone else, the solution can be found in https://github.com/lrusso/Emulatrix/blob/master/Emulatrix_DOSBox.htm.

Best regards, Leonardo