bit4sat/utils/paths.go

29 lines
387 B
Go
Raw Normal View History

2019-03-15 18:00:35 +00:00
package utils
import (
"os"
"path/filepath"
"strings"
2019-03-15 18:00:35 +00:00
)
const (
MkdirMode = 0770
)
func Mkdir(path ...string) error {
joined := filepath.Join(path...)
return os.MkdirAll(joined, MkdirMode)
}
func CleanFileName(path string) (name string, ext string) {
2019-03-21 17:44:40 +00:00
name = filepath.Base(path)
ext = filepath.Ext(name)
if len(ext) > 0 {
2019-03-21 17:44:40 +00:00
name = strings.Split(name, ".")[0]
}
return
}