rework 2 (working)
This commit is contained in:
parent
5a77fa5e9c
commit
d30ef6cc9c
48 changed files with 1340 additions and 1747 deletions
src/host/vfs
69
src/host/vfs/fs.go
Normal file
69
src/host/vfs/fs.go
Normal file
|
@ -0,0 +1,69 @@
|
|||
package vfs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/src/iio"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue