1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-25 02:44:41 -05:00
sub2clash/utils/mkdir.go

31 lines
577 B
Go
Raw Normal View History

package utils
import (
"errors"
"os"
)
func MKDir(dir string) error {
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, os.ModePerm)
if err != nil {
return err
}
}
return nil
}
func MkEssentialDir() error {
if err := MKDir("subs"); err != nil {
return errors.New("create subs dir failed" + err.Error())
}
if err := MKDir("templates"); err != nil {
return errors.New("create templates dir failed" + err.Error())
}
if err := MKDir("logs"); err != nil {
return errors.New("create logs dir failed" + err.Error())
}
return nil
}