diff --git a/data/dynos_bin_tex.cpp b/data/dynos_bin_tex.cpp index bac9f5d6..eb52cea1 100644 --- a/data/dynos_bin_tex.cpp +++ b/data/dynos_bin_tex.cpp @@ -419,8 +419,8 @@ static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath } // skip files that have already been generated - char buffer[1024]; - snprintf(buffer, 1024, "%s.tex", _Path.substr(0, _Path.size() - 4).c_str()); + char buffer[SYS_MAX_PATH]; + snprintf(buffer, SYS_MAX_PATH, "%s.tex", _Path.substr(0, _Path.size() - 4).c_str()); if (fs_sys_file_exists(buffer)) { continue; } diff --git a/src/pc/mods/mods.c b/src/pc/mods/mods.c index e601d8f8..46753c77 100644 --- a/src/pc/mods/mods.c +++ b/src/pc/mods/mods.c @@ -6,6 +6,10 @@ #include "pc/debuglog.h" #include "pc/loading.h" +#if defined(_WIN32) || defined(_WIN64) +#include +#endif + #define MAX_SESSION_CHARS 7 struct Mods gLocalMods = { 0 }; @@ -113,7 +117,12 @@ bool mods_generate_remote_base_path(void) { LOG_ERROR("Failed to concat tmp path"); return false; } - if (!fs_sys_dir_exists(tmpPath)) { fs_sys_mkdir(tmpPath); } + if (!fs_sys_dir_exists(tmpPath)) { + fs_sys_mkdir(tmpPath); +#if defined(_WIN32) || defined(_WIN64) + SetFileAttributesA(tmpPath, FILE_ATTRIBUTE_HIDDEN); +#endif + } // generate session char session[MAX_SESSION_CHARS + 1] = { 0 }; diff --git a/src/pc/mods/mods.h b/src/pc/mods/mods.h index 2935ba15..0b901362 100644 --- a/src/pc/mods/mods.h +++ b/src/pc/mods/mods.h @@ -8,7 +8,7 @@ #define MAX_MOD_SIZE (35 * 1048576) // 35MB #define MOD_DIRECTORY "mods" -#define TMP_DIRECTORY "tmp" +#define TMP_DIRECTORY ".tmp" struct Mods { struct Mod** entries; diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index bf774188..849dec98 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -373,7 +373,7 @@ int main(int argc, char *argv[]) { #endif - old_user_folder_handler(); + legacy_folder_handler(); const char *userpath = gCLIOpts.savePath[0] ? gCLIOpts.savePath : sys_user_path(); fs_init(userpath); diff --git a/src/pc/platform.h b/src/pc/platform.h index e9923623..3c9801ee 100644 --- a/src/pc/platform.h +++ b/src/pc/platform.h @@ -7,7 +7,7 @@ /* platform-specific functions and whatnot */ -#define SYS_MAX_PATH 4096 // FIXME: define this on different platforms +#define SYS_MAX_PATH 4096 // crossplatform impls of misc stuff char *sys_strdup(const char *src); diff --git a/src/pc/startup.cpp b/src/pc/startup.cpp index 1ffea3c4..3075f550 100644 --- a/src/pc/startup.cpp +++ b/src/pc/startup.cpp @@ -3,10 +3,15 @@ #include #include +#if defined(_WIN32) || defined(_WIN64) +#include +#endif + extern "C" { #include "platform.h" #include "mods/mods_utils.h" // for str_ends_with #include "mods/mod_cache.h" // for md5 hashing +#include "mods/mods.h" #include "loading.h" } @@ -30,16 +35,26 @@ static struct VanillaMD5 sVanillaMD5[] = { { NULL, NULL }, }; -static void copy_old_user_folder() { - char* oldpath = (char*)sys_old_user_path(); - char* newpath = (char*)sys_user_path(); - - if (fs::exists(oldpath) && (fs::is_empty(newpath) || !fs::exists(newpath))) { - fs::copy(oldpath, newpath); +inline static void copy_old_user_folder() { + std::string userPath = sys_user_path(); + std::string oldPath = sys_old_user_path(); + if (fs::exists(oldPath) && (fs::is_empty(userPath) || !fs::exists(userPath))) { + fs::copy(oldPath, userPath, fs::copy_options::recursive); gUserFolderCopied = true; } } +inline static void rename_tmp_folder() { + std::string userPath = sys_user_path(); + std::string oldPath = userPath + "/tmp"; + if (fs::exists(oldPath)) { +#if defined(_WIN32) || defined(_WIN64) + SetFileAttributesA(oldPath.c_str(), FILE_ATTRIBUTE_HIDDEN); +#endif + fs::rename(oldPath, userPath + "/" + TMP_DIRECTORY); + } +} + static bool is_rom_valid(const std::string romPath) { u8 dataHash[16] = { 0 }; mod_cache_md5(romPath.c_str(), dataHash); @@ -83,8 +98,9 @@ inline static bool scan_path_for_rom(const char *dir) { } extern "C" { -void old_user_folder_handler(void) { +void legacy_folder_handler(void) { copy_old_user_folder(); + if (gUserFolderCopied) { rename_tmp_folder(); } } bool main_rom_handler(void) { diff --git a/src/pc/startup.h b/src/pc/startup.h index fcb12b86..dff2bd2b 100644 --- a/src/pc/startup.h +++ b/src/pc/startup.h @@ -4,7 +4,7 @@ extern bool gUserFolderCopied; extern bool gRomIsValid; extern char gRomFilename[]; -void old_user_folder_handler(void); +void legacy_folder_handler(void); bool main_rom_handler(void); void rom_on_drop_file(const char *path);