Create fio wrapper for rename file

pull/569/head
Jonathan G Rennison 11 months ago
parent f190b9815a
commit f6e8ea059d

@ -360,6 +360,15 @@ void FioCreateDirectory(const std::string &name)
#endif
}
void FioRenameFile(const std::string &oldname, const std::string &newname)
{
#if defined(_WIN32)
_wrename(OTTD2FS(oldname).c_str(), OTTD2FS(newname).c_str());
#else
rename(oldname.c_str(), newname.c_str());
#endif
}
/**
* Appends, if necessary, the path separator character to the end of the string.
* It does not add the path separator to zero-sized strings.

@ -22,6 +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);
const char *FiosGetScreenshotDir();

@ -3735,7 +3735,7 @@ void DoAutoOrNetsave(FiosNumberedSaveName &counter, bool threaded, FiosNumberedS
std::string lt_path = lt_counter->FilenameUsingMaxSaves(_settings_client.gui.max_num_lt_autosaves);
DEBUG(sl, 2, "Renaming autosave '%s' to long-term file '%s'", buf, lt_path.c_str());
std::string dir = FioFindDirectory(AUTOSAVE_DIR);
rename((dir + buf).c_str(), (dir + lt_path).c_str());
FioRenameFile(dir + buf, dir + lt_path);
}
}

@ -220,7 +220,6 @@
# define fopen(file, mode) _wfopen(OTTD2FS(file).c_str(), _T(mode))
# define unlink(file) _wunlink(OTTD2FS(file).c_str())
# define rename(oldname, newname) _wrename(OTTD2FS(oldname).c_str(), OTTD2FS(newname).c_str())
std::string FS2OTTD(const std::wstring &name);
std::wstring OTTD2FS(const std::string &name);

Loading…
Cancel
Save