Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested entries #378

Open
TheCymaera opened this issue Jul 10, 2022 · 2 comments
Open

Nested entries #378

TheCymaera opened this issue Jul 10, 2022 · 2 comments

Comments

@TheCymaera
Copy link

TheCymaera commented Jul 10, 2022

It is common for IDEs and game-engine editors to specify resources using URIs or file paths.

To access a deeply nested file, we need to call getFileHandle and getDirectoryHandle recursively. Each level is an asynchronous operation that needs to be run sequentially.

I propose that the getFileHandle, getDirectoryHandle, and removeEntry methods be overloaded to accept an array/iterable argument.

directory.getFileHandle(["path", "to", "file.txt"]);

Alternatively, file names should accept slashes as delimiters.

directory.getFileHandle("path/to/file.txt");

The options parameter should include a createRecursive flag to complement the create flag.

directory.getFileHandle(["path", "to", "file.txt"], { createRecursive: true });
// Creates:
// path/
// path/to/
// path/to/file.txt
@guillaumebrunerie
Copy link

You can easily implement it yourself, not sure if there would be an advantage in making the spec more complicated for that?

@TheCymaera
Copy link
Author

TheCymaera commented Jan 18, 2023

Each level makes at least one file system call to check if the file exists. This takes anywhere between .2 to 1 milliseconds on the devices I've tried. The difference adds up quickly when processing multiple files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants