fehlerbehebung
This commit is contained in:
parent
992f39a475
commit
63e6f9ab9b
12
file.go
12
file.go
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue