tstor/src/host/vfs/utils.go

26 lines
444 B
Go
Raw Normal View History

2023-10-16 09:18:40 +00:00
package vfs
2023-12-21 23:15:39 +00:00
import "strings"
2023-10-16 09:18:40 +00:00
func trimRelPath(p, t string) string {
return strings.Trim(strings.TrimPrefix(p, t), "/")
}
2023-12-21 23:15:39 +00:00
// func clean(p string) string {
// return path.Clean(Separator + strings.ReplaceAll(p, "\\", "/"))
// }
func AbsPath(p string) string {
if p == "" || p[0] != '/' {
return Separator + p
}
return p
}
func AddTrailSlash(p string) string {
if p == "" || p[len(p)-1] != '/' {
return p + Separator
}
return p
2023-10-16 09:18:40 +00:00
}