This commit is contained in:
zeaslity
2025-02-26 17:49:03 +08:00
parent c751c21871
commit e8f0e0d4a9
3 changed files with 58 additions and 4 deletions

View File

@@ -236,6 +236,21 @@ func listAllFileInFolderWithFullPath(folderName string, fullPath bool) ([]string
return files, nil
}
// RemoveFile 删除文件如果文件不存在则返回true
func RemoveFile(filePath string) bool {
if _, err := os.Stat(filePath); os.IsNotExist(err) {
log.Error("文件不存在: %s", filePath)
return true
}
err := os.Remove(filePath)
if err != nil {
log.Error("Failed to remove file: %s", err.Error())
return false
}
return true
}
func RemoveFolderComplete(folderName string) bool {
err := filepath.Walk(folderName,