You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeFileInfointerface {
Name() string// base name of the fileSize() int64// length in bytes for regular files; system-dependent for othersMode() FileMode// file mode bitsModTime() time.Time// modification timeIsDir() bool// abbreviation for Mode().IsDir()Sys() any// underlying data source (can return nil)
}
Describe the solution you'd like
I think it makes the most sense to:
add Stat() (FileInfo, error) to the vfs.File interface
add Open(name string) (File, error) to the Location interface.
We could make vfs.Filesystem implement fs.FS so that you specify a the schema-less portion of the uri (authority + path) with Open(). Then both vfs.Location and vfs.File would implement fs.File.
osfs:=os.NewFileSystem()
// open a dirloc, _:= osfs.Open("c:/some/path/)
fileinfo,_ :=loc.Stat()
fmt.Printf("name: '%s'", fileinfo.Name()) // name: 'path'fmt.Printf("name: '%s'", loc.(*os.Location).Name()) // name: 'path'// open a filefile, _:=osfs.Open("c:/some/path/to/file.txt")
fileinfo,_:=file.Stat()
fmt.Printf("name: '%s'", fileinfo.Name()) // name: 'file.txt'fmt.Printf("name: '%s'", file.(*os.File).Name()) // name: 'file.txt'
Is your feature request related to a problem? Please describe.
Implement https://pkg.go.dev/io/fs#FS should consist of adding the following func
which returns a File:
where Stat() can return a FileInfo:
Describe the solution you'd like
I think it makes the most sense to:
Stat() (FileInfo, error)
to the vfs.File interfaceOpen(name string) (File, error)
to the Location interface.The implementation of Open could simply be:
The the overall usage would be like:
or for S3:
The text was updated successfully, but these errors were encountered: