Skip to content

Commit

Permalink
Merge pull request #102 from JAORMX/iofs-extra-interfaces-v5
Browse files Browse the repository at this point in the history
Enable the `iofs` adapter to also return other interfaces from `io/fs`
  • Loading branch information
pjbgf authored Jan 10, 2025
2 parents a6c6b50 + 21beb15 commit 0009381
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions helper/iofs/iofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ func New(fs billyfs.Basic) fs.FS {
return &adapterFs{fs: polyfill.New(fs)}
}

// NewStatFS adapts a billy.Filesystem to a io.fs.StatFS.
func NewStatFS(fs billyfs.Basic) fs.StatFS {
return &adapterFs{fs: polyfill.New(fs)}
}

// NewReadDirFS adapts a billy.Filesystem to a io.fs.ReadDirFS.
func NewReadDirFS(fs billyfs.Basic) fs.ReadDirFS {
return &adapterFs{fs: polyfill.New(fs)}
}

// NewReadFileFS adapts a billy.Filesystem to a io.fs.ReadFileFS.
func NewReadFileFS(fs billyfs.Basic) fs.ReadFileFS {
return &adapterFs{fs: polyfill.New(fs)}
}

type adapterFs struct {
fs billyfs.Filesystem
}
Expand Down

0 comments on commit 0009381

Please sign in to comment.