Return success boolean from FioRenameFile

tmp-jgrpp
Jonathan G Rennison 1 month ago
parent 4d0af08aad
commit 5e87d95013

@ -374,12 +374,18 @@ void FioCreateDirectory(const std::string &name)
#endif
}
void FioRenameFile(const std::string &oldname, const std::string &newname)
/**
* Renames a file from oldname to newname.
* @param oldname file name to rename from
* @param newname file name to rename to
* @return true iff the operation succeeded
*/
bool FioRenameFile(const std::string &oldname, const std::string &newname)
{
#if defined(_WIN32)
_wrename(OTTD2FS(oldname).c_str(), OTTD2FS(newname).c_str());
return _wrename(OTTD2FS(oldname).c_str(), OTTD2FS(newname).c_str()) == 0;
#else
rename(oldname.c_str(), newname.c_str());
return rename(oldname.c_str(), newname.c_str()) == 0;
#endif
}

@ -22,7 +22,7 @@ std::string FioFindFullPath(Subdirectory subdir, const std::string &filename);
std::string FioGetDirectory(Searchpath sp, Subdirectory subdir);
std::string FioFindDirectory(Subdirectory subdir);
void FioCreateDirectory(const std::string &name);
void FioRenameFile(const std::string &oldname, const std::string &newname);
bool FioRenameFile(const std::string &oldname, const std::string &newname);
const char *FiosGetScreenshotDir();

Loading…
Cancel
Save