iofs_file.go 485 B

12345678910111213141516171819202122232425262728
  1. package iofswrap
  2. import (
  3. "github.com/spf13/afero"
  4. "io/fs"
  5. )
  6. var _ fs.File = (*IOFSFileWrapper)(nil)
  7. func NewFileWrapper(afile afero.File) fs.File {
  8. return &IOFSFileWrapper{afile: afile}
  9. }
  10. type IOFSFileWrapper struct {
  11. afile afero.File
  12. }
  13. func (w IOFSFileWrapper) Stat() (fs.FileInfo, error) {
  14. return w.afile.Stat()
  15. }
  16. func (w IOFSFileWrapper) Read(bytes []byte) (int, error) {
  17. return w.afile.Read(bytes)
  18. }
  19. func (w IOFSFileWrapper) Close() error {
  20. return w.afile.Close()
  21. }