Create fio wrapper for rename file
This commit is contained in:
@@ -360,6 +360,15 @@ void FioCreateDirectory(const std::string &name)
|
|||||||
#endif
|
#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.
|
* Appends, if necessary, the path separator character to the end of the string.
|
||||||
* It does not add the path separator to zero-sized strings.
|
* 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 FioGetDirectory(Searchpath sp, Subdirectory subdir);
|
||||||
std::string FioFindDirectory(Subdirectory subdir);
|
std::string FioFindDirectory(Subdirectory subdir);
|
||||||
void FioCreateDirectory(const std::string &name);
|
void FioCreateDirectory(const std::string &name);
|
||||||
|
void FioRenameFile(const std::string &oldname, const std::string &newname);
|
||||||
|
|
||||||
const char *FiosGetScreenshotDir();
|
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);
|
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());
|
DEBUG(sl, 2, "Renaming autosave '%s' to long-term file '%s'", buf, lt_path.c_str());
|
||||||
std::string dir = FioFindDirectory(AUTOSAVE_DIR);
|
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 fopen(file, mode) _wfopen(OTTD2FS(file).c_str(), _T(mode))
|
||||||
# define unlink(file) _wunlink(OTTD2FS(file).c_str())
|
# 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::string FS2OTTD(const std::wstring &name);
|
||||||
std::wstring OTTD2FS(const std::string &name);
|
std::wstring OTTD2FS(const std::string &name);
|
||||||
|
Reference in New Issue
Block a user