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
763 B

7 years ago
5 years ago
7 years ago
7 years ago
7 years ago
7 years ago
5 years ago
  1. package filer2
  2. import (
  3. "path/filepath"
  4. "strings"
  5. "github.com/chrislusf/seaweedfs/weed/util"
  6. )
  7. type FullPath string
  8. func NewFullPath(dir, name string) FullPath {
  9. return FullPath(dir).Child(name)
  10. }
  11. func (fp FullPath) DirAndName() (string, string) {
  12. dir, name := filepath.Split(string(fp))
  13. if dir == "/" {
  14. return dir, name
  15. }
  16. if len(dir) < 1 {
  17. return "/", ""
  18. }
  19. return dir[:len(dir)-1], name
  20. }
  21. func (fp FullPath) Name() string {
  22. _, name := filepath.Split(string(fp))
  23. return name
  24. }
  25. func (fp FullPath) Child(name string) FullPath {
  26. dir := string(fp)
  27. if strings.HasSuffix(dir, "/") {
  28. return FullPath(dir + name)
  29. }
  30. return FullPath(dir + "/" + name)
  31. }
  32. func (fp FullPath) AsInode() uint64 {
  33. return uint64(util.HashStringToLong(string(fp)))
  34. }