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

Select directory relative to a specific file #46

Closed
SinZ163 opened this issue Apr 23, 2019 · 2 comments
Closed

Select directory relative to a specific file #46

SinZ163 opened this issue Apr 23, 2019 · 2 comments
Milestone

Comments

@SinZ163
Copy link

SinZ163 commented Apr 23, 2019

A common pattern when a known file structure is known ahead of time is to ask the user to select a well known file in the file structure and use that to obtain the directory.

This is to provide a level of validation so the user doesn't select a folder that won't match the correct file structure and used a lot in mod managers.

Example, there is some executable file MyGame.exe and you want to add files to the same folder, rather than having a directory picker and the user potentially picking any folder, they have a filepicker instead that only accepts MyGame.exe as input.

@mkruisselbrink mkruisselbrink added this to the Future milestone Apr 16, 2020
@jencibacsi
Copy link

@mkruisselbrink :

Another argument (and a solution proposal):

I can call the showOpenFilePicker() method with a FileSystemFileHandle in the "startIn" parameter - the dialog starts in the directory of the file (in which the file resides).
There is getFileHandle() method (fileHandle = await directoryHandle . getFileHandle(name)) with which the caller can get back a FileSystemFileHandle to a file by name in the given directory.
And there is a getDirectoryHandle() method (subdirHandle = await directoryHandle . getDirectoryHandle(name)) which returns a handle for a directory by name in the directory represented by directoryHandle.

Feature request:
directoryHandle = await fileHandle . getDirectoryHandle()
A method which returns a FileSystemDirectoryHandle which points to the directory in which the file resides...

@dslee414
Copy link
Collaborator

The workaround mentioned above of using startIn parameter might work for this use case. If the goal is to get the parent directory given a file handle, whatwg/fs#38 discusses a similar feature request.

@dslee414 dslee414 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
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

4 participants