diff options
| author | Dentomologist <dentomologist@gmail.com> | 2020-12-03 13:13:16 -0800 |
|---|---|---|
| committer | Dentomologist <dentomologist@gmail.com> | 2020-12-05 16:13:46 -0800 |
| commit | 4a55511e18c7bb912d882684d591d110576deb47 (patch) | |
| tree | e35aabb68213aae6f8b11fbff2c99d16ca5da6d9 /Source/Core/Common/FileUtil.cpp | |
| parent | c434eefe94c73978605cf4dfe1459d2f8ede0858 (diff) | |
Add warning flags to File deletion functions
Adds a flag to File::Delete and File::DeleteDir functions to control
whether a console warning is emitted when the file or directory doesn't
exist. The flag is optional and true by default to match current behavior.
Diffstat (limited to 'Source/Core/Common/FileUtil.cpp')
| -rw-r--r-- | Source/Core/Common/FileUtil.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 6039a449fa..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,14 +256,17 @@ 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)) { - WARN_LOG_FMT(COMMON, "DeleteDir: {} does not exist", filename); + if (behavior == IfAbsentBehavior::ConsoleWarning) + { + WARN_LOG_FMT(COMMON, "DeleteDir: {} does not exist", filename); + } return true; } |
