Codechange: Introduce FioRemove() to remove files. (#12491)

New function FioRemove() handles OTTD2FS conversion, and uses std::filesystem::remove instead of unlink, all in one location.
This commit is contained in:
Peter Nelson
2024-04-14 23:43:50 +01:00
committed by GitHub
parent 29e932e087
commit 4eaeccdaeb
7 changed files with 25 additions and 14 deletions

View File

@@ -19,12 +19,6 @@
#include "fileio_func.h"
#include <sstream>
#ifdef _WIN32
# include <windows.h>
#else
# include <unistd.h>
#endif /* _WIN32 */
#include "safeguards.h"
std::string _ini_videodriver; ///< The video driver a stored in the configuration file.
@@ -129,7 +123,7 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t
* hardware acceleration. */
auto filename = FioFindFullPath(BASE_DIR, HWACCELERATION_TEST_FILE);
if (!filename.empty()) {
unlink(filename.c_str());
FioRemove(filename);
Debug(driver, 1, "Probing {} driver '{}' skipped due to earlier crash", GetDriverTypeName(type), d->name);
@@ -216,7 +210,7 @@ void DriverFactoryBase::MarkVideoDriverOperational()
* and as we are operational now, remove the hardware acceleration
* test-file. */
auto filename = FioFindFullPath(BASE_DIR, HWACCELERATION_TEST_FILE);
if (!filename.empty()) unlink(filename.c_str());
if (!filename.empty()) FioRemove(filename);
}
/**