fehlerbehebung

This commit is contained in:
xoy 2023-01-29 16:13:57 +01:00
parent 992f39a475
commit 63e6f9ab9b
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) { func fileCreate(filepath string) {
if !fileExist(filepath) { if _, err := os.Stat(filepath); err == nil {
_, err := os.Create(filepath) _, err := os.Create(filepath)
errorPanic(err) errorPanic(err)
logger("fileCreate : file created -> " + filepath) logger("fileCreate : file created -> " + filepath)
} else { } else if errors.Is(err, os.ErrNotExist) {
logger("fileCreate : file already exists -> " + filepath) logger("fileCreate : file already exists -> " + filepath)
} else {
logger("fileCreate : unknown -> " + filepath)
} }
} }
func fileCreateDir(dirpath string) { func fileCreateDir(dirpath string) {
if fileExist(dirpath) { if _, err := os.Stat(dirpath); err == nil {
err := os.Mkdir(dirpath, 0755) err := os.Mkdir(dirpath, 0755)
errorPanic(err) errorPanic(err)
logger("fileCreateDir : folder created -> " + dirpath) logger("fileCreateDir : folder created -> " + dirpath)
} else { } else if errors.Is(err, os.ErrNotExist) {
logger("fileCreateDir : folder not created -> " + dirpath) logger("fileCreateDir : folder not created -> " + dirpath)
} else {
logger("fileCreateDir : unknown -> " + dirpath)
} }
} }