summaryrefslogtreecommitdiff
path: root/Source/Core/Common/FileUtil.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-12-11 02:06:28 +0100
committerGitHub <noreply@github.com>2020-12-11 02:06:28 +0100
commit2e63cc8313f01b7720f555ba72219f134eb298fa (patch)
tree1b1cd45f9d8970d15e3dd1bf04c7136127bd223d /Source/Core/Common/FileUtil.cpp
parent75899b0e1121f01afdd606e1dd3a5822fa408530 (diff)
parent760e7e664a38065c0bd1dbe978852ca85a48a160 (diff)
Merge pull request #9307 from Dentomologist/add-deleted-file-missing-warning-flag
Add File::Delete and File::DeleteDir warning flags
Diffstat (limited to 'Source/Core/Common/FileUtil.cpp')
-rw-r--r--Source/Core/Common/FileUtil.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index 5e8868da21..0d41395209 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -135,7 +135,7 @@ bool IsFile(const std::string& path)
// Deletes a given filename, return true on success
// Doesn't supports deleting a directory
-bool Delete(const std::string& filename)
+bool Delete(const std::string& filename, IfAbsentBehavior behavior)
{
INFO_LOG_FMT(COMMON, "Delete: file {}", filename);
@@ -154,7 +154,10 @@ bool Delete(const std::string& filename)
// Return true because we care about the file not being there, not the actual delete.
if (!file_info.Exists())
{
- WARN_LOG_FMT(COMMON, "Delete: {} does not exist", filename);
+ if (behavior == IfAbsentBehavior::ConsoleWarning)
+ {
+ WARN_LOG_FMT(COMMON, "Delete: {} does not exist", filename);
+ }
return true;
}
@@ -253,10 +256,20 @@ bool CreateFullPath(const std::string& fullPath)
}
// Deletes a directory filename, returns true on success
-bool DeleteDir(const std::string& filename)
+bool DeleteDir(const std::string& filename, IfAbsentBehavior behavior)
{
INFO_LOG_FMT(COMMON, "DeleteDir: directory {}", filename);
+ // Return true because we care about the directory not being there, not the actual delete.
+ if (!File::Exists(filename))
+ {
+ if (behavior == IfAbsentBehavior::ConsoleWarning)
+ {
+ WARN_LOG_FMT(COMMON, "DeleteDir: {} does not exist", filename);
+ }
+ return true;
+ }
+
// check if a directory
if (!IsDirectory(filename))
{