2019-03-15 18:00:35 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2019-03-20 18:39:38 +00:00
|
|
|
"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)
|
|
|
|
}
|
2019-03-20 18:39:38 +00:00
|
|
|
|
|
|
|
func CleanFileName(path string) (name string, ext string) {
|
|
|
|
|
2019-03-21 17:44:40 +00:00
|
|
|
name = filepath.Base(path)
|
|
|
|
ext = filepath.Ext(name)
|
2019-03-20 18:39:38 +00:00
|
|
|
if len(ext) > 0 {
|
2019-03-21 17:44:40 +00:00
|
|
|
name = strings.Split(name, ".")[0]
|
2019-03-20 18:39:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|