fehlerbehebung

This commit is contained in:
xoy 2023-01-29 16:13:57 +01:00
parent 8031477f38
commit 024214120f
1 changed files with 8 additions and 4 deletions

12
file.go
View File

@ -29,23 +29,27 @@ func fileAddLine(input string, filepath string) {
}
func fileCreate(filepath string) {
if !fileExist(filepath) {
if _, err := os.Stat(filepath); err == nil {
_, err := os.Create(filepath)
errorPanic(err)
logger("fileCreate : file created -> " + filepath)
} else {
} else if errors.Is(err, os.ErrNotExist) {
logger("fileCreate : file already exists -> " + filepath)
} else {
logger("fileCreate : unknown -> " + filepath)
}
}
func fileCreateDir(dirpath string) {
if fileExist(dirpath) {
if _, err := os.Stat(dirpath); err == nil {
err := os.Mkdir(dirpath, 0755)
errorPanic(err)
logger("fileCreateDir : folder created -> " + dirpath)
} else {
} else if errors.Is(err, os.ErrNotExist) {
logger("fileCreateDir : folder not created -> " + dirpath)
} else {
logger("fileCreateDir : unknown -> " + dirpath)
}
}