From e80d1661216d58c693ab5cb85038a87b040b3081 Mon Sep 17 00:00:00 2001 From: Erik Unger Date: Mon, 28 Aug 2023 21:14:30 +0200 Subject: [PATCH] aliases --- dropboxfs/dropboxfs.go | 3 +-- file.go | 12 ++++++------ fileinfo.go | 6 +++--- filereader.go | 5 ++--- filesystem.go | 15 ++++++++++----- fsimpl/direntry.go | 10 +++++----- fsimpl/filebuffer.go | 25 +++++++++++++------------ invalidfilesystem.go | 11 +++++------ localfilesystem.go | 10 +++++----- memfile.go | 16 ++++++++-------- memfilesystem.go | 5 ++--- permissions.go | 4 ++-- readonlybase.go | 4 +--- s3fs/fileinfo.go | 16 ++++++++-------- s3fs/s3fs.go | 3 +-- sftpfs/sftpfs.go | 4 ++-- stddirentry.go | 8 ++++---- stdfs.go | 24 ++++++++++++------------ subfilesystem.go | 11 +++++------ zipfs/zipfs.go | 2 +- 20 files changed, 96 insertions(+), 98 deletions(-) diff --git a/dropboxfs/dropboxfs.go b/dropboxfs/dropboxfs.go index 15cc8e5..0a15a20 100644 --- a/dropboxfs/dropboxfs.go +++ b/dropboxfs/dropboxfs.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "errors" - "io" iofs "io/fs" "path" "strings" @@ -345,7 +344,7 @@ func (dbfs *DropboxFileSystem) OpenReader(filePath string) (iofs.File, error) { return fsimpl.NewReadonlyFileBuffer(data, info), nil } -func (dbfs *DropboxFileSystem) OpenWriter(filePath string, perm []fs.Permissions) (io.WriteCloser, error) { +func (dbfs *DropboxFileSystem) OpenWriter(filePath string, perm []fs.Permissions) (fs.WriteCloser, error) { if !dbfs.info(path.Dir(filePath)).IsDir { return nil, fs.NewErrIsNotDirectory(dbfs.File(path.Dir(filePath))) } diff --git a/file.go b/file.go index 0bba5c6..c471efb 100644 --- a/file.go +++ b/file.go @@ -9,7 +9,7 @@ import ( "errors" "fmt" "io" - "io/fs" + iofs "io/fs" "strings" "time" @@ -186,7 +186,7 @@ func (file File) Joinf(format string, args ...interface{}) File { } // Stat returns a standard library io/fs.FileInfo describing the file. -func (file File) Stat() (fs.FileInfo, error) { +func (file File) Stat() (iofs.FileInfo, error) { if file == "" { return nil, ErrEmptyPath } @@ -693,7 +693,7 @@ func (file File) ReadFrom(reader io.Reader) (n int64, err error) { if file == "" { return 0, ErrEmptyPath } - var writer io.WriteCloser + var writer WriteCloser existingPerm := file.Permissions() if existingPerm != NoPermissions { writer, err = file.OpenWriter(existingPerm) @@ -708,7 +708,7 @@ func (file File) ReadFrom(reader io.Reader) (n int64, err error) { } // OpenReader opens the file and returns a io/fs.File that has to be closed after reading -func (file File) OpenReader() (fs.File, error) { +func (file File) OpenReader() (ReadCloser, error) { if file == "" { return nil, ErrEmptyPath } @@ -740,7 +740,7 @@ func (file File) OpenReadSeeker() (ReadSeekCloser, error) { return fsimpl.NewReadonlyFileBufferReadAll(readCloser, info) } -func (file File) OpenWriter(perm ...Permissions) (io.WriteCloser, error) { +func (file File) OpenWriter(perm ...Permissions) (WriteCloser, error) { if file == "" { return nil, ErrEmptyPath } @@ -748,7 +748,7 @@ func (file File) OpenWriter(perm ...Permissions) (io.WriteCloser, error) { return fileSystem.OpenWriter(path, perm) } -func (file File) OpenAppendWriter(perm ...Permissions) (io.WriteCloser, error) { +func (file File) OpenAppendWriter(perm ...Permissions) (WriteCloser, error) { if file == "" { return nil, ErrEmptyPath } diff --git a/fileinfo.go b/fileinfo.go index ad973cb..0b847c2 100644 --- a/fileinfo.go +++ b/fileinfo.go @@ -1,7 +1,7 @@ package fs import ( - "io/fs" + iofs "io/fs" "os" "time" ) @@ -26,7 +26,7 @@ type FileInfo struct { // of an existing file. // Use NewNonExistingFileInfo to get // a FileInfo for non existing file. -func NewFileInfo(file File, info fs.FileInfo, hidden bool) FileInfo { +func NewFileInfo(file File, info iofs.FileInfo, hidden bool) FileInfo { mode := info.Mode() return FileInfo{ File: file, @@ -58,7 +58,7 @@ func NewNonExistingFileInfo(file File) FileInfo { // StdFileInfo returns an io/fs.FileInfo wrapper // for the data stored in the FileInfo struct. -func (i *FileInfo) StdFileInfo() fs.FileInfo { return fileInfo{i} } +func (i *FileInfo) StdFileInfo() iofs.FileInfo { return fileInfo{i} } // fileInfo implements os.FileInfo and fs.FileInfo for a given FileInfo type fileInfo struct{ i *FileInfo } diff --git a/filereader.go b/filereader.go index d31504b..cb8e826 100644 --- a/filereader.go +++ b/filereader.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/fs" "github.com/ungerik/go-fs/fsimpl" ) @@ -58,8 +57,8 @@ type FileReader interface { // WriteTo implements the io.WriterTo interface WriteTo(writer io.Writer) (n int64, err error) - // OpenReader opens the file and returns a io/fs.File that has to be closed after reading - OpenReader() (fs.File, error) + // OpenReader opens the file and returns a ReadCloser that has to be closed after reading + OpenReader() (ReadCloser, error) // OpenReadSeeker opens the file and returns a ReadSeekCloser. // Use OpenReader if seeking is not necessary because implementations diff --git a/filesystem.go b/filesystem.go index b2a3e39..fac6aff 100644 --- a/filesystem.go +++ b/filesystem.go @@ -3,7 +3,12 @@ package fs import ( "context" "io" - "io/fs" + iofs "io/fs" +) + +type ( + ReadCloser = iofs.File + WriteCloser = io.WriteCloser ) // FileSystem is an interface that has to be implemented for @@ -59,7 +64,7 @@ type FileSystem interface { // If filePath is the root of the file systeme, then an empty string will be returned for name. SplitDirAndName(filePath string) (dir, name string) - Stat(filePath string) (fs.FileInfo, error) + Stat(filePath string) (iofs.FileInfo, error) // IsHidden returns if a file is hidden depending // on the definition of hidden files of the file system, @@ -90,8 +95,8 @@ type FileSystem interface { MakeDir(dirPath string, perm []Permissions) error - OpenReader(filePath string) (fs.File, error) - OpenWriter(filePath string, perm []Permissions) (io.WriteCloser, error) + OpenReader(filePath string) (ReadCloser, error) + OpenWriter(filePath string, perm []Permissions) (WriteCloser, error) OpenReadWriter(filePath string, perm []Permissions) (ReadWriteSeekCloser, error) // Remove deletes the file. @@ -218,7 +223,7 @@ type AppendFileSystem interface { type AppendWriterFileSystem interface { FileSystem - OpenAppendWriter(filePath string, perm []Permissions) (io.WriteCloser, error) + OpenAppendWriter(filePath string, perm []Permissions) (WriteCloser, error) } type TruncateFileSystem interface { diff --git a/fsimpl/direntry.go b/fsimpl/direntry.go index 1708077..2b343af 100644 --- a/fsimpl/direntry.go +++ b/fsimpl/direntry.go @@ -1,15 +1,15 @@ package fsimpl -import "io/fs" +import iofs "io/fs" // DirEntryFromFileInfo wraps a io/fs.FileInfo as io/fs.DirEntry. -func DirEntryFromFileInfo(info fs.FileInfo) fs.DirEntry { +func DirEntryFromFileInfo(info iofs.FileInfo) iofs.DirEntry { return dirEntry{info} } type dirEntry struct { - fs.FileInfo + iofs.FileInfo } -func (dir dirEntry) Type() fs.FileMode { return dir.Mode() } -func (dir dirEntry) Info() (fs.FileInfo, error) { return dir.FileInfo, nil } +func (dir dirEntry) Type() iofs.FileMode { return dir.Mode() } +func (dir dirEntry) Info() (iofs.FileInfo, error) { return dir.FileInfo, nil } diff --git a/fsimpl/filebuffer.go b/fsimpl/filebuffer.go index 90691da..f29b544 100644 --- a/fsimpl/filebuffer.go +++ b/fsimpl/filebuffer.go @@ -3,30 +3,31 @@ package fsimpl import ( "errors" "io" - "io/fs" + iofs "io/fs" ) -var _ fs.File = new(ReadonlyFileBuffer) +var _ iofs.File = new(ReadonlyFileBuffer) // ReadonlyFileBuffer is a memory buffer that implements ReadSeekCloser which combines the interfaces -// io/fs.File -// io.Reader -// io.ReaderAt -// io.Seeker -// io.Closer +// +// io/fs.File +// io.Reader +// io.ReaderAt +// io.Seeker +// io.Closer type ReadonlyFileBuffer struct { - info fs.FileInfo + info iofs.FileInfo data []byte pos int64 // current reading index close func() error } // NewReadonlyFileBuffer returns a new ReadonlyFileBuffer -func NewReadonlyFileBuffer(data []byte, info fs.FileInfo) *ReadonlyFileBuffer { +func NewReadonlyFileBuffer(data []byte, info iofs.FileInfo) *ReadonlyFileBuffer { return &ReadonlyFileBuffer{data: data, info: info} } -func NewReadonlyFileBufferReadAll(reader io.Reader, info fs.FileInfo) (*ReadonlyFileBuffer, error) { +func NewReadonlyFileBufferReadAll(reader io.Reader, info iofs.FileInfo) (*ReadonlyFileBuffer, error) { data, err := io.ReadAll(reader) if err != nil { return nil, err @@ -35,11 +36,11 @@ func NewReadonlyFileBufferReadAll(reader io.Reader, info fs.FileInfo) (*Readonly } // NewReadonlyFileBufferWithClose returns a new ReadonlyFileBuffer -func NewReadonlyFileBufferWithClose(data []byte, info fs.FileInfo, close func() error) *ReadonlyFileBuffer { +func NewReadonlyFileBufferWithClose(data []byte, info iofs.FileInfo, close func() error) *ReadonlyFileBuffer { return &ReadonlyFileBuffer{data: data, info: info, close: close} } -func (buf *ReadonlyFileBuffer) Stat() (fs.FileInfo, error) { +func (buf *ReadonlyFileBuffer) Stat() (iofs.FileInfo, error) { return buf.info, nil } diff --git a/invalidfilesystem.go b/invalidfilesystem.go index 8af04b6..16ee69c 100644 --- a/invalidfilesystem.go +++ b/invalidfilesystem.go @@ -2,8 +2,7 @@ package fs import ( "context" - "io" - "io/fs" + iofs "io/fs" "net/url" "path" "strings" @@ -94,7 +93,7 @@ func (InvalidFileSystem) VolumeName(filePath string) string { return "invalid:" } -func (InvalidFileSystem) Stat(filePath string) (fs.FileInfo, error) { +func (InvalidFileSystem) Stat(filePath string) (iofs.FileInfo, error) { return nil, ErrInvalidFileSystem } @@ -166,15 +165,15 @@ func (InvalidFileSystem) Append(ctx context.Context, filePath string, data []byt return ErrInvalidFileSystem } -func (InvalidFileSystem) OpenReader(filePath string) (fs.File, error) { +func (InvalidFileSystem) OpenReader(filePath string) (ReadCloser, error) { return nil, ErrInvalidFileSystem } -func (InvalidFileSystem) OpenWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (InvalidFileSystem) OpenWriter(filePath string, perm []Permissions) (WriteCloser, error) { return nil, ErrInvalidFileSystem } -func (InvalidFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (InvalidFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (WriteCloser, error) { return nil, ErrInvalidFileSystem } diff --git a/localfilesystem.go b/localfilesystem.go index 6646699..341cc63 100644 --- a/localfilesystem.go +++ b/localfilesystem.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "io" - "io/fs" + iofs "io/fs" "net/url" "os" "os/user" @@ -181,7 +181,7 @@ func (local *LocalFileSystem) VolumeName(filePath string) string { return filepath.VolumeName(filePath) } -func (local *LocalFileSystem) Stat(filePath string) (fs.FileInfo, error) { +func (local *LocalFileSystem) Stat(filePath string) (iofs.FileInfo, error) { filePath = expandTilde(filePath) info, err := os.Stat(filePath) if err != nil { @@ -551,7 +551,7 @@ func (local *LocalFileSystem) Append(ctx context.Context, filePath string, data return err } -func (local *LocalFileSystem) OpenReader(filePath string) (fs.File, error) { +func (local *LocalFileSystem) OpenReader(filePath string) (ReadCloser, error) { if filePath == "" { return nil, ErrEmptyPath } @@ -560,7 +560,7 @@ func (local *LocalFileSystem) OpenReader(filePath string) (fs.File, error) { return f, wrapOSErr(filePath, err) } -func (local *LocalFileSystem) OpenWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (local *LocalFileSystem) OpenWriter(filePath string, perm []Permissions) (WriteCloser, error) { if filePath == "" { return nil, ErrEmptyPath } @@ -570,7 +570,7 @@ func (local *LocalFileSystem) OpenWriter(filePath string, perm []Permissions) (i return f, wrapOSErr(filePath, err) } -func (local *LocalFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (local *LocalFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (WriteCloser, error) { if filePath == "" { return nil, ErrEmptyPath } diff --git a/memfile.go b/memfile.go index 751b84b..480e8e4 100644 --- a/memfile.go +++ b/memfile.go @@ -8,7 +8,7 @@ import ( "encoding/xml" "fmt" "io" - "io/fs" + iofs "io/fs" "strings" "time" @@ -231,7 +231,7 @@ func (f MemFile) WriteTo(writer io.Writer) (n int64, err error) { } // OpenReader opens the file and returns a io/fs.File that has to be closed after reading -func (f MemFile) OpenReader() (fs.File, error) { +func (f MemFile) OpenReader() (ReadCloser, error) { return fsimpl.NewReadonlyFileBuffer(f.FileData, memFileInfo{f}), nil } @@ -324,11 +324,11 @@ func (f *MemFile) Write(b []byte) (int, error) { } // Stat returns a io/fs.FileInfo describing the MemFile. -func (f MemFile) Stat() (fs.FileInfo, error) { +func (f MemFile) Stat() (iofs.FileInfo, error) { return memFileInfo{f}, nil } -var _ fs.FileInfo = memFileInfo{} +var _ iofs.FileInfo = memFileInfo{} // memFileInfo implements io/fs.FileInfo for a MemFile. // @@ -337,7 +337,7 @@ type memFileInfo struct { MemFile } -func (i memFileInfo) Mode() fs.FileMode { return 0666 } -func (i memFileInfo) ModTime() time.Time { return time.Now() } -func (i memFileInfo) IsDir() bool { return false } -func (i memFileInfo) Sys() interface{} { return nil } +func (i memFileInfo) Mode() iofs.FileMode { return 0666 } +func (i memFileInfo) ModTime() time.Time { return time.Now() } +func (i memFileInfo) IsDir() bool { return false } +func (i memFileInfo) Sys() interface{} { return nil } diff --git a/memfilesystem.go b/memfilesystem.go index 0673088..592647b 100644 --- a/memfilesystem.go +++ b/memfilesystem.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "io" iofs "io/fs" "net/url" "path" @@ -555,11 +554,11 @@ func (fs *MemFileSystem) OpenReader(filePath string) (iofs.File, error) { return nil, nil } -func (fs *MemFileSystem) OpenWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (fs *MemFileSystem) OpenWriter(filePath string, perm []Permissions) (WriteCloser, error) { return nil, nil } -func (fs *MemFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (fs *MemFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (WriteCloser, error) { return nil, nil } diff --git a/permissions.go b/permissions.go index 057e1f9..451c171 100644 --- a/permissions.go +++ b/permissions.go @@ -1,7 +1,7 @@ package fs import ( - "io/fs" + iofs "io/fs" "os" ) @@ -98,6 +98,6 @@ func JoinPermissions(perms []Permissions, defaultPerm Permissions) (result Permi return result } -func PermissionsFromStdFileInfo(info fs.FileInfo) Permissions { +func PermissionsFromStdFileInfo(info iofs.FileInfo) Permissions { return Permissions(info.Mode().Perm()) } diff --git a/readonlybase.go b/readonlybase.go index 3bc79bc..106a0ee 100644 --- a/readonlybase.go +++ b/readonlybase.go @@ -1,8 +1,6 @@ package fs import ( - "io" - "github.com/ungerik/go-fs/fsimpl" ) @@ -47,7 +45,7 @@ func (*ReadOnlyBase) MakeDir(dirPath string, perm []Permissions) error { return ErrReadOnlyFileSystem } -func (*ReadOnlyBase) OpenWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (*ReadOnlyBase) OpenWriter(filePath string, perm []Permissions) (WriteCloser, error) { return nil, ErrReadOnlyFileSystem } diff --git a/s3fs/fileinfo.go b/s3fs/fileinfo.go index e789235..1fb702f 100644 --- a/s3fs/fileinfo.go +++ b/s3fs/fileinfo.go @@ -1,11 +1,11 @@ package s3fs import ( - "io/fs" + iofs "io/fs" "time" ) -var _ fs.FileInfo = new(fileInfo) +var _ iofs.FileInfo = new(fileInfo) type fileInfo struct { name string @@ -13,9 +13,9 @@ type fileInfo struct { time time.Time } -func (i *fileInfo) Name() string { return i.name } // base name of the file -func (i *fileInfo) Size() int64 { return i.size } // length in bytes for regular files; system-dependent for others -func (i *fileInfo) Mode() fs.FileMode { return 0600 } // file mode bits -func (i *fileInfo) ModTime() time.Time { return i.time } // modification time -func (i *fileInfo) IsDir() bool { return false } // abbreviation for Mode().IsDir() -func (i *fileInfo) Sys() any { return nil } // underlying data source (can return nil) +func (i *fileInfo) Name() string { return i.name } // base name of the file +func (i *fileInfo) Size() int64 { return i.size } // length in bytes for regular files; system-dependent for others +func (i *fileInfo) Mode() iofs.FileMode { return 0600 } // file mode bits +func (i *fileInfo) ModTime() time.Time { return i.time } // modification time +func (i *fileInfo) IsDir() bool { return false } // abbreviation for Mode().IsDir() +func (i *fileInfo) Sys() any { return nil } // underlying data source (can return nil) diff --git a/s3fs/s3fs.go b/s3fs/s3fs.go index 084eb17..e6597a4 100644 --- a/s3fs/s3fs.go +++ b/s3fs/s3fs.go @@ -5,7 +5,6 @@ import ( "context" "errors" "fmt" - "io" iofs "io/fs" "path" "strings" @@ -397,7 +396,7 @@ func (s *S3FileSystem) OpenReader(filePath string) (iofs.File, error) { return fsimpl.NewReadonlyFileBuffer(data, info), nil } -func (s *S3FileSystem) OpenWriter(filePath string, perm []fs.Permissions) (io.WriteCloser, error) { +func (s *S3FileSystem) OpenWriter(filePath string, perm []fs.Permissions) (fs.WriteCloser, error) { if filePath == "" { return nil, fs.ErrEmptyPath } diff --git a/sftpfs/sftpfs.go b/sftpfs/sftpfs.go index 2b5cda0..9453f7a 100644 --- a/sftpfs/sftpfs.go +++ b/sftpfs/sftpfs.go @@ -172,11 +172,11 @@ func (f *SFTPFileSystem) MakeDir(dirPath string, perm []fs.Permissions) error { return f.client.Mkdir(dirPath) } -func (f *SFTPFileSystem) OpenWriter(filePath string, perm []fs.Permissions) (io.WriteCloser, error) { +func (f *SFTPFileSystem) OpenWriter(filePath string, perm []fs.Permissions) (fs.WriteCloser, error) { return f.client.Open(filePath) } -func (f *SFTPFileSystem) OpenAppendWriter(filePath string, perm []fs.Permissions) (io.WriteCloser, error) { +func (f *SFTPFileSystem) OpenAppendWriter(filePath string, perm []fs.Permissions) (fs.WriteCloser, error) { file, err := f.client.Open(filePath) if err != nil { return nil, err diff --git a/stddirentry.go b/stddirentry.go index 3394b88..a884acb 100644 --- a/stddirentry.go +++ b/stddirentry.go @@ -1,9 +1,9 @@ package fs -import "io/fs" +import iofs "io/fs" var ( - _ fs.DirEntry = StdDirEntry{File("")} + _ iofs.DirEntry = StdDirEntry{File("")} ) // StdDirEntry implements the io/fs.DirEntry interface @@ -26,7 +26,7 @@ func (de StdDirEntry) IsDir() bool { // Type returns the type bits for the entry. // The type bits are a subset of the usual FileMode bits, those returned by the FileMode.Type method. -func (de StdDirEntry) Type() fs.FileMode { +func (de StdDirEntry) Type() iofs.FileMode { stat, err := de.File.Stat() if err != nil { return 0 @@ -40,6 +40,6 @@ func (de StdDirEntry) Type() fs.FileMode { // since the directory read, Info may return an error satisfying errors.Is(err, ErrNotExist). // If the entry denotes a symbolic link, Info reports the information about the link itself, // not the link's target. -func (de StdDirEntry) Info() (fs.FileInfo, error) { +func (de StdDirEntry) Info() (iofs.FileInfo, error) { return de.File.Stat() } diff --git a/stdfs.go b/stdfs.go index 9aa4fa5..24febe3 100644 --- a/stdfs.go +++ b/stdfs.go @@ -3,19 +3,19 @@ package fs import ( "errors" "fmt" - "io/fs" + iofs "io/fs" "path" "sort" "strings" ) var ( - _ fs.FS = StdFS{File("")} - _ fs.SubFS = StdFS{File("")} - _ fs.StatFS = StdFS{File("")} - _ fs.GlobFS = StdFS{File("")} - _ fs.ReadDirFS = StdFS{File("")} - _ fs.ReadFileFS = StdFS{File("")} + _ iofs.FS = StdFS{File("")} + _ iofs.SubFS = StdFS{File("")} + _ iofs.StatFS = StdFS{File("")} + _ iofs.GlobFS = StdFS{File("")} + _ iofs.ReadDirFS = StdFS{File("")} + _ iofs.ReadFileFS = StdFS{File("")} ) // StdFS implements the io/fs.FS interface @@ -35,21 +35,21 @@ type StdFS struct { // Stat returns a io/fs.FileInfo describing the file. // // This method implements the io/fs.StatFS interface. -func (f StdFS) Stat(name string) (fs.FileInfo, error) { +func (f StdFS) Stat(name string) (iofs.FileInfo, error) { return f.File.Join(name).Stat() } // Sub returns an io/fs.FS corresponding to the subtree rooted at dir. // // This method implements the io/fs.SubFS interface. -func (f StdFS) Sub(dir string) (fs.FS, error) { +func (f StdFS) Sub(dir string) (iofs.FS, error) { return f.File.Join(dir).StdFS(), nil } // Open opens the named file. // // This method implements the io/fs.FS interface. -func (f StdFS) Open(name string) (fs.File, error) { +func (f StdFS) Open(name string) (iofs.File, error) { if err := checkStdFSName(name); err != nil { return nil, err } @@ -70,11 +70,11 @@ func (f StdFS) ReadFile(name string) ([]byte, error) { // and returns a list of directory entries sorted by filename. // // This method implements the io/fs.ReadDirFS interface. -func (f StdFS) ReadDir(name string) ([]fs.DirEntry, error) { +func (f StdFS) ReadDir(name string) ([]iofs.DirEntry, error) { if err := checkStdFSName(name); err != nil { return nil, err } - var entries []fs.DirEntry + var entries []iofs.DirEntry err := f.File.Join(name).ListDir(func(file File) error { entries = append(entries, file.StdDirEntry()) return nil diff --git a/subfilesystem.go b/subfilesystem.go index 7b071cf..95afd63 100644 --- a/subfilesystem.go +++ b/subfilesystem.go @@ -2,8 +2,7 @@ package fs import ( "context" - "io" - "io/fs" + iofs "io/fs" "path/filepath" "github.com/ungerik/go-fs/fsimpl" @@ -119,7 +118,7 @@ func (subfs *todoSubFileSystem) AbsPath(filePath string) string { return subfs.Parent.AbsPath(filePath) } -func (subfs *todoSubFileSystem) Stat(filePath string) (fs.FileInfo, error) { +func (subfs *todoSubFileSystem) Stat(filePath string) (iofs.FileInfo, error) { return subfs.Parent.Stat(filePath) } @@ -187,15 +186,15 @@ func (subfs *todoSubFileSystem) WriteAll(ctx context.Context, filePath string, d panic("not implemented") } -func (subfs *todoSubFileSystem) OpenReader(filePath string) (fs.File, error) { +func (subfs *todoSubFileSystem) OpenReader(filePath string) (ReadCloser, error) { panic("not implemented") } -func (subfs *todoSubFileSystem) OpenWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (subfs *todoSubFileSystem) OpenWriter(filePath string, perm []Permissions) (WriteCloser, error) { panic("not implemented") } -func (subfs *todoSubFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (io.WriteCloser, error) { +func (subfs *todoSubFileSystem) OpenAppendWriter(filePath string, perm []Permissions) (WriteCloser, error) { panic("not implemented") } diff --git a/zipfs/zipfs.go b/zipfs/zipfs.go index d4f881a..3b4d7da 100644 --- a/zipfs/zipfs.go +++ b/zipfs/zipfs.go @@ -346,7 +346,7 @@ func (zipfs *ZipFileSystem) MakeDir(dirPath string, perm []fs.Permissions) error return nil } -func (zipfs *ZipFileSystem) OpenWriter(filePath string, perm []fs.Permissions) (io.WriteCloser, error) { +func (zipfs *ZipFileSystem) OpenWriter(filePath string, perm []fs.Permissions) (fs.WriteCloser, error) { if zipfs.zipWriter == nil { return nil, fs.ErrReadOnlyFileSystem }