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 216 forks source link

Using MountableFileSystem with a backend other than `InMemory` #337

Closed NovaAndrom3da closed 1 year ago

NovaAndrom3da commented 1 year ago

In the MountableFileSystem documentation, it describes how it acts as a standard InMemory filesystem. Is there any way I could use it instead with IndexedDB?

DustinBrett commented 1 year ago

I have an example of this working on my project if you're interested.

https://github.com/DustinBrett/daedalOS/blob/main/contexts/fileSystem/FileSystemConfig.ts

{
  fs: "MountableFileSystem",
  options: {
    "/": {
      fs: "OverlayFS",
      options: {
        readable: {
          fs: "HTTPRequest",
          options: { index },
        },
        writable: {
          fs: writeToMemory ? "InMemory" : "IndexedDB",
        },
      },
    },
  },
}
james-pre commented 1 year ago

You can simply mount an overlayFS (overlaying an IndexedDB FS) to "/".

DustinBrett commented 1 year ago

That's true you may not even need MountableFileSystem depending on your use case. For me I use it because I mount other FS's after load such as IsoFS or ZipFS.

james-pre commented 1 year ago

@Froggo8311 Has your question been answered?