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.

42 lines
694 B

  1. package mount
  2. import (
  3. "bytes"
  4. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  5. "github.com/hanwen/go-fuse/v2/fs"
  6. "strings"
  7. )
  8. type Directory struct {
  9. fs.Inode
  10. name string
  11. wfs *WFS
  12. entry *filer_pb.Entry
  13. parent *Directory
  14. id uint64
  15. }
  16. func (dir *Directory) FullPath() string {
  17. var parts []string
  18. for p := dir; p != nil; p = p.parent {
  19. if strings.HasPrefix(p.name, "/") {
  20. if len(p.name) > 1 {
  21. parts = append(parts, p.name[1:])
  22. }
  23. } else {
  24. parts = append(parts, p.name)
  25. }
  26. }
  27. if len(parts) == 0 {
  28. return "/"
  29. }
  30. var buf bytes.Buffer
  31. for i := len(parts) - 1; i >= 0; i-- {
  32. buf.WriteString("/")
  33. buf.WriteString(parts[i])
  34. }
  35. return buf.String()
  36. }