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

View file

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