Skip to content

Conversation

dolmen
Copy link

@dolmen dolmen commented Mar 26, 2025

Add an optional io/fs.FS to filepicker's model to allow to browse an abstracted filesystem as an alternative to the full filesystem exposed by the os package.

The filepicker API is extended (and generalized thanks to io/fs.FS), without any breaking change.

This allows for example to browse limited a subdirectory by using os.Root (go1.24+):

fp := filepicker.New()
root, _ := os.OpenRoot(dir)
fp.FS = root.FS()

Note that Go 1.25 will add io/fs.ReadLink, but we can't use it yet. So we implement symlink resolution here.

By the way, references to os types and constants which are aliases to same symbols in io/fs are replaced: os.Mode*, os.DirEntry.

Example

See package github.com/dolmen-go/iofs-shell.

Runnable example:

$ go run github.com/dolmen-go/iofs-shell/examples/browse-zip <file>.zip

@dolmen dolmen requested a review from bashbunni as a code owner March 26, 2025 00:48
@dolmen dolmen changed the title filepicker: add support for abstracted filesystem io/fs.FS feat(filepicker): add support for abstracted filesystem io/fs.FS Mar 26, 2025
Add an optional io/fs.FS to filepicker's model to allow to browse an
abstracted filesystem instead of the full filesystem exposed by the 'os'
package.

Note that Go 1.25 will add io/fs.ReadLink, but we can't use it yet. So
we implement symlink resolution here.

By the way, references to os types and constants which are aliases to
same symbols in io/fs are replaced: os.Mode*, os.DirEntry.
@dolmen dolmen force-pushed the filepicker-add-support-for-fs.FS branch from 5646902 to a0d6cf8 Compare March 26, 2025 00:57
dolmen added a commit to dolmen-go/iofs-shell that referenced this pull request Apr 1, 2025
This requires so far my fork of bubbles/filepicker that allows to browse
an io/fs.FS (see charmbracelet/bubbles#759).
@dolmen
Copy link
Author

dolmen commented Apr 1, 2025

Cc: @maaslalani (filepicker original author) for review

@dolmen
Copy link
Author

dolmen commented May 26, 2025

Cc: @meowgorithm for review

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

Successfully merging this pull request may close these issues.

1 participant