diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-06-02 00:35:03 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-06-02 00:35:03 -0700 |
| commit | c546c309f10154688431433c031d62dc20edfc85 (patch) | |
| tree | 69670656b3f740cd1f05e8fe646d2cae51c9aff5 /weed/filer2/fullpath.go | |
| parent | 3a3553dc463a8f5f5739b58e325da4f14650517b (diff) | |
| parent | a146a48ccc16848a9c2f24b64864e9566db8ab7c (diff) | |
| download | seaweedfs-c546c309f10154688431433c031d62dc20edfc85.tar.xz seaweedfs-c546c309f10154688431433c031d62dc20edfc85.zip | |
Merge branch 'filer2_development'
Diffstat (limited to 'weed/filer2/fullpath.go')
| -rw-r--r-- | weed/filer2/fullpath.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/weed/filer2/fullpath.go b/weed/filer2/fullpath.go new file mode 100644 index 000000000..be6e34431 --- /dev/null +++ b/weed/filer2/fullpath.go @@ -0,0 +1,31 @@ +package filer2 + +import ( + "path/filepath" + "strings" +) + +type FullPath string + +func NewFullPath(dir, name string) FullPath { + if strings.HasSuffix(dir, "/") { + return FullPath(dir + name) + } + return FullPath(dir + "/" + name) +} + +func (fp FullPath) DirAndName() (string, string) { + dir, name := filepath.Split(string(fp)) + if dir == "/" { + return dir, name + } + if len(dir) < 1 { + return "/", "" + } + return dir[:len(dir)-1], name +} + +func (fp FullPath) Name() string { + _, name := filepath.Split(string(fp)) + return name +} |
