package helper import ( "os" "gitbase.de/apairon/mark2web/pkg/logger" ) // CreateDirectory creates direcory with all missing parents and panic if error func CreateDirectory(dir string) { logger.D("trying to create output directory: %s", dir) if dirH, err := os.Stat(dir); os.IsNotExist(err) { err := os.MkdirAll(dir, 0755) logger.Eexit(err, "could not create output directory '%s'", dir) logger.I("created output directory: %s", dir) } else if dirH != nil { if dirH.IsDir() { logger.I("output directory '%s' already exists", dir) } else { logger.Exit("output directory '%s' is no directory", dir) } } else { logger.Perr(err, "unknown error for output directory '%s'", dir) } }