Skip to content

Commit 0009381

Browse files
authored
Merge pull request #102 from JAORMX/iofs-extra-interfaces-v5
Enable the `iofs` adapter to also return other interfaces from `io/fs`
2 parents a6c6b50 + 21beb15 commit 0009381

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

helper/iofs/iofs.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ func New(fs billyfs.Basic) fs.FS {
1616
return &adapterFs{fs: polyfill.New(fs)}
1717
}
1818

19+
// NewStatFS adapts a billy.Filesystem to a io.fs.StatFS.
20+
func NewStatFS(fs billyfs.Basic) fs.StatFS {
21+
return &adapterFs{fs: polyfill.New(fs)}
22+
}
23+
24+
// NewReadDirFS adapts a billy.Filesystem to a io.fs.ReadDirFS.
25+
func NewReadDirFS(fs billyfs.Basic) fs.ReadDirFS {
26+
return &adapterFs{fs: polyfill.New(fs)}
27+
}
28+
29+
// NewReadFileFS adapts a billy.Filesystem to a io.fs.ReadFileFS.
30+
func NewReadFileFS(fs billyfs.Basic) fs.ReadFileFS {
31+
return &adapterFs{fs: polyfill.New(fs)}
32+
}
33+
1934
type adapterFs struct {
2035
fs billyfs.Filesystem
2136
}

0 commit comments

Comments
 (0)