mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-28 05:15:00 +08:00
32 lines
522 B
Go
32 lines
522 B
Go
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
|
|
}
|