mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-23 20:45:11 +00:00
Rename tmp to .tmp and hide on Windows (Will test after making this commit)
This commit is contained in:
parent
12aff40090
commit
591261fd41
7 changed files with 39 additions and 14 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#include "pc/debuglog.h"
|
||||
#include "pc/loading.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
#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 };
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -3,10 +3,15 @@
|
|||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h>
|
||||
#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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue