whatwg / fs

File System Standard
https://fs.spec.whatwg.org/
Other
224 stars 19 forks source link

POSIX style path access for OPFS #161

Closed msqr1 closed 5 months ago

msqr1 commented 5 months ago

What problem are you trying to solve?

When we want to go into a directory hierarchy, we have to keep getting FileSystemDirectoryHandle for the child, until we reach what we want. Same goes for checking if a file exists, we have to traverse through the hierarchy by keep getting FileSystemDirectoryHandle just to iterate to all entries and compare. Same goes for making directories, creating files nested in hierchies,...

What solutions exist today?

We can create a recursive function that split paths and handle relative paths and stuff.

How would you solve it?

It would be nice to have native method such as:

getDirectoryHandle(path : String, cwd?: FileSystemDirectoryHandle, {create?})
getFileHandle(path : String, cwd?: FileSystemDirectoryHandle, {create?})

These can take in the cwd argument for relative path, or we can even implement a current working directory global variable. If path starts with ../ then cwd must be specified