quick patch: don't rename tmp folder if .tmp already exists (#48)

if ex-coop is ran after the tmp folder is renamed, a new tmp folder will be created, which coopdx will then attempt to rename on the next run and fail to do so since .tmp already exists, resulting in the game failing to open
This commit is contained in:
Cooliokid956 2024-05-19 21:42:06 -05:00 committed by GitHub
parent f5db61f864
commit bb34e9f501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -38,11 +38,12 @@ static struct VanillaMD5 sVanillaMD5[] = {
inline static void rename_tmp_folder() {
std::string userPath = fs_get_write_path("");
std::string oldPath = userPath + "tmp";
if (fs::exists(oldPath)) {
std::string newPath = userPath + TMP_DIRECTORY;
if (fs::exists(oldPath) && !fs::exists(newPath)) {
#if defined(_WIN32) || defined(_WIN64)
SetFileAttributesA(oldPath.c_str(), FILE_ATTRIBUTE_HIDDEN);
#endif
fs::rename(oldPath, userPath + TMP_DIRECTORY);
fs::rename(oldPath, newPath);
}
}