Skip to content

Return concrete *os.FS from Sub() and Subvolume() #40

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions os/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewFS() *FS {

// SubVolume is like Sub, but only sets the volume name (i.e. for Windows).
// Calling SubVolume again on the returned FS results in an error.
func (fs *FS) SubVolume(volumeName string) (hackpadfs.FS, error) {
func (fs *FS) SubVolume(volumeName string) (*FS, error) {
if fs.root != "" {
return nil, &hackpadfs.PathError{Op: "subvolume", Path: volumeName, Err: errors.New("subvolume not supported on a SubFS")}
}
Expand All @@ -48,7 +48,7 @@ func (fs *FS) SubVolume(volumeName string) (hackpadfs.FS, error) {
}

// Sub implements hackpadfs.SubFS
func (fs *FS) Sub(dir string) (hackpadfs.FS, error) {
func (fs *FS) Sub(dir string) (*FS, error) {
if !hackpadfs.ValidPath(dir) {
return nil, &hackpadfs.PathError{Op: "sub", Path: dir, Err: hackpadfs.ErrInvalid}
}
Expand Down
4 changes: 2 additions & 2 deletions os/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestFSTest(t *testing.T) {
if !assert.NoError(tb, err) {
tb.FailNow()
}
fs = subvFS.(*FS)
fs = subvFS
dir = dir[len(volumeName)+1:]
} else {
dir = strings.TrimPrefix(dir, "/")
Expand All @@ -40,7 +40,7 @@ func TestFSTest(t *testing.T) {
if !assert.NoError(tb, err) {
tb.FailNow()
}
return subFS.(*FS)
return subFS
},
}
var skipFacets []fstest.Facets
Expand Down