2020-09-27 19:23:47 +00:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
2021-11-23 12:05:49 +00:00
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
2023-10-08 16:46:03 +00:00
|
|
|
"git.kmsign.ru/royalcat/tstor/src/iio"
|
2020-09-27 19:23:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type File interface {
|
|
|
|
IsDir() bool
|
|
|
|
Size() int64
|
|
|
|
|
|
|
|
iio.Reader
|
|
|
|
}
|
|
|
|
|
|
|
|
type Filesystem interface {
|
|
|
|
// Open opens the named file for reading. If successful, methods on the
|
|
|
|
// returned file can be used for reading; the associated file descriptor has
|
|
|
|
// mode O_RDONLY.
|
|
|
|
Open(filename string) (File, error)
|
|
|
|
|
|
|
|
// ReadDir reads the directory named by dirname and returns a list of
|
|
|
|
// directory entries.
|
|
|
|
ReadDir(path string) (map[string]File, error)
|
|
|
|
}
|
2021-11-23 12:05:49 +00:00
|
|
|
|
|
|
|
type fileInfo struct {
|
|
|
|
name string
|
|
|
|
size int64
|
|
|
|
isDir bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewFileInfo(name string, size int64, isDir bool) *fileInfo {
|
|
|
|
return &fileInfo{
|
|
|
|
name: name,
|
|
|
|
size: size,
|
|
|
|
isDir: isDir,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi *fileInfo) Name() string {
|
|
|
|
return fi.name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi *fileInfo) Size() int64 {
|
|
|
|
return fi.size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi *fileInfo) Mode() os.FileMode {
|
|
|
|
if fi.isDir {
|
|
|
|
return 0555 | os.ModeDir
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0555
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi *fileInfo) ModTime() time.Time {
|
|
|
|
// TODO fix it
|
|
|
|
return time.Now()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi *fileInfo) IsDir() bool {
|
|
|
|
return fi.isDir
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi *fileInfo) Sys() interface{} {
|
|
|
|
return nil
|
|
|
|
}
|