php-wasm
php-wasm copied to clipboard
Ability to handle files on a fly
Instead of creating files upfront, I'd like to see the ability to create them on a fly (for the performance reasons).
For example when FS.open() is called and the file doesn't exist, give the parent module ability to create it.
Proposed solution (right before returning ErrnoError(44):
+ if (!node && Module && Module["onFileOpen"]) {
+ node = Module["onFileOpen"](path, this);
+ }
if (!node) {
throw new FS.ErrnoError(44);
}
Then the caller module can define something like:
onFileOpen: function (path, fs) {
var node = this["FS_createDataFile"](fs.cwd(), path, "foo", true, true, true);
return node;
},
For example, Drupal got over 20k files, why not create only these files which are requested during the run.