WICG / file-system-access

Expose the file system on the user’s device, so Web apps can interoperate with the user’s native applications.
https://wicg.github.io/file-system-access/
Other
667 stars 66 forks source link

Resolve() a directory #355

Closed DDS9 closed 1 year ago

DDS9 commented 2 years ago

Very early days here, so forgive what is probably a very basic question. Having created a directory handle, the name property reveals only a single term. How does one efficiently resolve the absolute path of the directory the user has selected? I was trying to create a label with the absolute path as a confirmation to the user they had selected the correct folder. eg. "C:/myapp/data/xml/" - but all I can find to print is "xml", using the name property.

Is it a question of taking the first file entry, resolving that, and then trimming the array? Passing null to the resolve() method would seem intuitive, but it demands a non-null file handle.

Or are paths all relative paths to the directoryHandle? Hence the path is effectively empty for a chosen directoryHandle?

Thank you.

a-sully commented 1 year ago

This is by design - absolute paths are not supported by this API. dir.resolve(blah) will give you the relative paths between dir and blah if one exists, but there's intentionally no way to say "give me C:/myapp/data/xml"

The closest thing is the ability to specify that you want the file picker opened to a WellKnownDirectory, though the AppData of a natively installed app isn't one of those locations...