backive/utils.go

18 lines
362 B
Go
Raw Normal View History

package backive
import (
"log"
"os"
)
2022-01-07 11:17:12 +01:00
// CreateDirectoryIfNotExists Checks for a directory string and creates the directory if it does not exist, must be a absolute path.
func CreateDirectoryIfNotExists(dir string) {
if _, err := os.Stat(dir); err == nil {
//ignore
} else if os.IsNotExist(err) {
os.MkdirAll(dir, 0755)
} else {
log.Fatal(err)
}
}