file-system-access icon indicating copy to clipboard operation
file-system-access copied to clipboard

Clarify how the API deals with hidden files

Open tomayac opened this issue 5 years ago • 5 comments

Should the API be aware of hidden files? Something like .gitignore may well be suitable for a Web-based IDE to display. FWIW, the macOS file picker preview doesn't show hidden files (even if I have decided on a system level to show them), but hidden files are then included in the directory listing (notice the missing .gitignore in the file picker):

Screen Shot 2020-02-17 at 14 55 12

Should a File object have a hidden flag, since the UNIX convention to prefix hidden files with a . doesn't exist on Windows for example?

tomayac avatar Feb 17 '20 13:02 tomayac

Hidden files are part of the filesystem and should stay included in the directory listing, they are just hidden for the user. Files like .gitignore, .editorconfig, .npmrc,... are also useful and sometimes needed in a Web-based IDE .

The hidden flag seems to be very useful when you present files to the user,...

+1 for the hidden flag idea

veith avatar Feb 17 '20 14:02 veith

(You can play with this code at https://github.com/GoogleChromeLabs/browser-nativefs#live-demo.)

tomayac avatar Feb 17 '20 15:02 tomayac

Good question, yes, I agree that hidden files should be exposed by the API, but we probably do indeed want to somehow expose the "hidden" flag to the web. This kind feels like part of the bigger question of what other metadata about files we should expose (although "hidden" is perhaps different since it not only applies to files but also to directories).

Related question is if it should be possible to create new hidden files/directories? On platforms where the "hidden" state of a file is merely the fact that the name starts with a "." it is effectively already possible to do so, but on windows it is not currently possible. Should it be possible on windows as well?

mkruisselbrink avatar Apr 09 '20 18:04 mkruisselbrink

Seems reasonable to support this on Windows, as well. We could expose an isHidden attribute as part of the file metadata (proposed here https://github.com/whatwg/fs/issues/12) and add a new flag to getFileHandle(), though we'd have to specify how that behaves with the name parameter

Most OS file pickers don't show hidden files and AFAIK there's no way to configure that programmatically (please correct me if I'm wrong)

I have some reservations about making a given file hidden, since from the perspective of the user it could appear as if the file is removed (especially if the site does not have access to the parent). Perhaps there should be some restrictions on file moves (see https://github.com/whatwg/fs/issues/10)... though remove self (https://github.com/whatwg/fs/issues/9) is soon to be supported so perhaps that's not a big deal

Anywho, this seems nice to have so I'll leave the issue open, but I don't see us prioritizing this any time soon

a-sully avatar Jan 09 '23 22:01 a-sully

I think a FileSystemHandle.hidden property would be very useful, especially for storing settings from a web app.

aetinx avatar Apr 02 '24 22:04 aetinx