aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/fullpath.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filer2/fullpath.go')
-rw-r--r--weed/filer2/fullpath.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/weed/filer2/fullpath.go b/weed/filer2/fullpath.go
index be6e34431..133069f93 100644
--- a/weed/filer2/fullpath.go
+++ b/weed/filer2/fullpath.go
@@ -3,15 +3,14 @@ package filer2
import (
"path/filepath"
"strings"
+
+ "github.com/chrislusf/seaweedfs/weed/util"
)
type FullPath string
func NewFullPath(dir, name string) FullPath {
- if strings.HasSuffix(dir, "/") {
- return FullPath(dir + name)
- }
- return FullPath(dir + "/" + name)
+ return FullPath(dir).Child(name)
}
func (fp FullPath) DirAndName() (string, string) {
@@ -29,3 +28,15 @@ func (fp FullPath) Name() string {
_, name := filepath.Split(string(fp))
return name
}
+
+func (fp FullPath) Child(name string) FullPath {
+ dir := string(fp)
+ if strings.HasSuffix(dir, "/") {
+ return FullPath(dir + name)
+ }
+ return FullPath(dir + "/" + name)
+}
+
+func (fp FullPath) AsInode() uint64 {
+ return uint64(util.HashStringToLong(string(fp)))
+}