mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-23 22:14:41 -05:00
31 lines
577 B
Go
31 lines
577 B
Go
|
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
|
||
|
}
|