You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
736 B

7 years ago
7 years ago
  1. package filesys
  2. import (
  3. "context"
  4. "fmt"
  5. "bazil.org/fuse"
  6. "github.com/chrislusf/seaweedfs/weed/filer"
  7. )
  8. type File struct {
  9. FileId filer.FileId
  10. Name string
  11. wfs *WFS
  12. }
  13. func (file *File) Attr(context context.Context, attr *fuse.Attr) error {
  14. attr.Mode = 0444
  15. ret, err := filer.GetFileSize(file.wfs.filer, string(file.FileId))
  16. if err == nil {
  17. attr.Size = ret.Size
  18. } else {
  19. fmt.Printf("Get file %s attr [ERROR] %s\n", file.Name, err)
  20. }
  21. return err
  22. }
  23. func (file *File) ReadAll(ctx context.Context) ([]byte, error) {
  24. ret, err := filer.GetFileContent(file.wfs.filer, string(file.FileId))
  25. if err == nil {
  26. return ret.Content, nil
  27. }
  28. fmt.Printf("Get file %s content [ERROR] %s\n", file.Name, err)
  29. return nil, err
  30. }