diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-05-05 22:47:16 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-05-05 22:47:16 -0700 |
| commit | 456738ba6482118ad95fea0a694ca33036921612 (patch) | |
| tree | e8691f4e878cf6b09562aaa28feb5bc3ad8b7477 /weed/filesys/file.go | |
| parent | 2cada598c6b3bf1fe2c3619dd75dcde7391aec35 (diff) | |
| download | seaweedfs-456738ba6482118ad95fea0a694ca33036921612.tar.xz seaweedfs-456738ba6482118ad95fea0a694ca33036921612.zip | |
refactoring fuse
Diffstat (limited to 'weed/filesys/file.go')
| -rw-r--r-- | weed/filesys/file.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/weed/filesys/file.go b/weed/filesys/file.go new file mode 100644 index 000000000..bb2e52113 --- /dev/null +++ b/weed/filesys/file.go @@ -0,0 +1,34 @@ +package filesys + +import ( + "bazil.org/fuse" + "fmt" + "github.com/chrislusf/seaweedfs/weed/filer" + "context" +) + +type File struct { + FileId filer.FileId + Name string + wfs *WFS +} + +func (file *File) Attr(context context.Context, attr *fuse.Attr) error { + attr.Mode = 0444 + ret, err := filer.GetFileSize(file.wfs.filer, string(file.FileId)) + if err == nil { + attr.Size = ret.Size + } else { + fmt.Printf("Get file %s attr [ERROR] %s\n", file.Name, err) + } + return err +} + +func (file *File) ReadAll(ctx context.Context) ([]byte, error) { + ret, err := filer.GetFileContent(file.wfs.filer, string(file.FileId)) + if err == nil { + return ret.Content, nil + } + fmt.Printf("Get file %s content [ERROR] %s\n", file.Name, err) + return nil, err +} |
