seaweedfs/weed/filer2/filer_structure.go

67 lines
1.5 KiB
Go
Raw Permalink Normal View History

2018-05-11 09:20:15 +00:00
package filer2
import (
"errors"
"os"
"time"
2018-05-12 20:45:29 +00:00
"path/filepath"
2018-05-11 09:20:15 +00:00
)
type FileId string //file id in SeaweedFS
2018-05-12 20:45:29 +00:00
type FullPath string
func (fp FullPath) DirAndName() (string, string) {
dir, name := filepath.Split(string(fp))
if dir == "/" {
return dir, name
}
if len(dir) < 1 {
return "/", ""
}
return dir[:len(dir)-1], name
2018-05-11 09:20:15 +00:00
}
type Attr struct {
2018-05-12 20:45:29 +00:00
Mtime time.Time // time of last modification
Crtime time.Time // time of creation (OS X only)
Mode os.FileMode // file mode
Uid uint32 // owner uid
Gid uint32 // group gid
2018-05-11 09:20:15 +00:00
}
type Entry struct {
2018-05-12 20:45:29 +00:00
FullPath
2018-05-11 09:20:15 +00:00
Attr
// the following is for files
Chunks []FileChunk `json:"chunks,omitempty"`
}
type FileChunk struct {
Fid FileId `json:"fid,omitempty"`
Offset int64 `json:"offset,omitempty"`
Size uint64 `json:"size,omitempty"` // size in bytes
}
type AbstractFiler interface {
2018-05-12 20:45:29 +00:00
CreateEntry(*Entry) (error)
2018-05-11 09:20:15 +00:00
AppendFileChunk(FullPath, FileChunk) (err error)
2018-05-12 20:45:29 +00:00
FindEntry(FullPath) (found bool, fileEntry *Entry, err error)
DeleteEntry(FullPath) (fileEntry *Entry, err error)
2018-05-11 09:20:15 +00:00
2018-05-12 20:45:29 +00:00
ListDirectoryEntries(dirPath FullPath) ([]*Entry, error)
UpdateEntry(*Entry) (error)
2018-05-11 09:20:15 +00:00
}
var ErrNotFound = errors.New("filer: no entry is found in filer store")
type FilerStore interface {
2018-05-12 20:45:29 +00:00
InsertEntry(*Entry) (error)
2018-05-11 09:20:15 +00:00
AppendFileChunk(FullPath, FileChunk) (err error)
2018-05-12 20:45:29 +00:00
FindEntry(FullPath) (found bool, entry *Entry, err error)
DeleteEntry(FullPath) (fileEntry *Entry, err error)
2018-05-11 09:20:15 +00:00
2018-05-12 20:45:29 +00:00
ListDirectoryEntries(dirPath FullPath) ([]*Entry, error)
2018-05-11 09:20:15 +00:00
}