emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

discussion - feasibility to integrate `https://wicg.github.io/file-system-access/`

Open kaizhu256 opened this issue 5 years ago • 4 comments
trafficstars

a serious limitation of downstream libraries like sql.js is inability to persist largish databases (e.g. 1gb) to local filesystem.

that might finally be overcome with newly proposed https://wicg.github.io/file-system-access (note spec's motivation appears mainly saving data in web-editors and ides). they have an experimental demo here

feasibility question - what additional spec read/write features are needed to integrate emscripten with file-system-access?

spec's current read/write capabilities are (from what i gather):

read

  • await FileSystemHandle.file() // method returns blob/file object

write

  • await FileSystemWritableFileStream.write(data)
  • await FileSystemWritableFileStream.write({ type: "write", data: data })
  • await FileSystemWritableFileStream.write({ type: "write", position: position, data: data })
  • await FileSystemWritableFileStream.write({ type: "seek", position: position })
  • await FileSystemWritableFileStream.write({ type: "truncate", size: size })

kaizhu256 avatar Oct 03 '20 23:10 kaizhu256

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

stale[bot] avatar Apr 17 '22 22:04 stale[bot]

@tlively is this the same thing you are working on with wasmfs+opfs?

sbc100 avatar Apr 19 '22 15:04 sbc100

Very related, but the API in the OP accesses and stores data to the user's file system rather than a private file system as in OPFS.

tlively avatar Apr 19 '22 18:04 tlively

Very related, but the API in the OP accesses and stores data to the user's file system rather than a private file system as in OPFS.

tested, you can replace the let root = await navigator.storage.getDirectory(); in the compiled output with

        let root;
        await new Promise((res, rej) => {
          const button = document.createElement("button")
          button.onclick = async () => {
            root = await window.showDirectoryPicker({mode:"readwrite"});
            res();
          }
          button.textContent = "Click me to proceed";
          document.body.appendChild(button);
        })

and it works fine, the emscripten code can access the local files. The button is created because showDirectoryPicker can only be run as a result of user interaction

ProgrammerIn-wonderland avatar Jul 27 '24 01:07 ProgrammerIn-wonderland