moth/cmd/mothd/common.go

20 lines
400 B
Go
Raw Normal View History

2019-09-02 18:42:27 -06:00
package main
import (
"path/filepath"
"strings"
)
func MothPath(base string, parts ...string) string {
path := filepath.Clean(filepath.Join(parts...))
parts = filepath.SplitList(path)
for i, part := range parts {
part = strings.TrimLeft(part, "./\\:")
parts[i] = part
}
parts = append([]string{base}, parts...)
path = filepath.Join(parts...)
path = filepath.Clean(path)
return path
}