1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-23 22:14:41 -05:00
sub2clash/common/mkdir.go
Nite07 ac4ad3c8aa ♻️ Refactor code
🔥 Remove update detection
2024-04-23 14:47:53 +08:00

31 lines
578 B
Go

package common
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
}