From 8fb7e8d80eb73afc94e895abda64f6af794963e1 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 25 Mar 2023 05:08:23 -0700 Subject: [PATCH] FHU: Add RenameFile helper --- FEXHeaderUtils/FEXHeaderUtils/Filesystem.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/FEXHeaderUtils/FEXHeaderUtils/Filesystem.h b/FEXHeaderUtils/FEXHeaderUtils/Filesystem.h index d249f0415..5b26ea91a 100644 --- a/FEXHeaderUtils/FEXHeaderUtils/Filesystem.h +++ b/FEXHeaderUtils/FEXHeaderUtils/Filesystem.h @@ -200,6 +200,18 @@ namespace FHU::Filesystem { return false; } + /** + * @brief Renames a file and overwrites if it already exists. + * + * @param From + * @param To + * + * @return True if the rename occured, False otherwise. + */ + inline bool RenameFile(const fextl::string &From, const fextl::string &To) { + return rename(From.c_str(), To.c_str()) == 0; + } + inline fextl::string LexicallyNormal(const fextl::string &Path) { const auto PathSize = Path.size();