fix: Create Pro machine profile directories

This commit is contained in:
voidderef
2026-09-13 19:53:44 +02:00
parent c550b3f9b5
commit b2dd6bbc26
3 changed files with 36 additions and 4 deletions
+17 -1
View File
@@ -27,6 +27,7 @@
#include "util/fs.h"
#include "util/glibc.h"
#include "util/log.h"
#include "util/str.h"
#include "util/sys-info.h"
#include "options.h"
@@ -81,6 +82,21 @@ static void prohook_fs_redir_settings(struct prohook_options *options)
}
}
char *machine_profile_path =
util_str_merge(options->game.settings, "/MachineProfile");
if (!util_fs_path_exists(machine_profile_path)) {
log_info(
"Machine profile path %s does not exist, creating",
machine_profile_path);
if (!util_fs_mkdir(machine_profile_path)) {
log_error("Creating directory %s failed", machine_profile_path);
}
}
free(machine_profile_path);
char *abs_path = util_fs_get_abs_path(options->game.settings);
cnh_redir_add("/data", abs_path);
@@ -239,4 +255,4 @@ void prohook_trap_after_main(void)
LIB_MAIN_CONSTRUCTOR(prohook_constructor);
LIB_MAIN_DESTRUCTOR(prohook_destructor);
LIB_MAIN_TRAP_MAIN(prohook_trap_before_main, prohook_trap_after_main);
LIB_MAIN_TRAP_MAIN(prohook_trap_before_main, prohook_trap_after_main);
+17 -1
View File
@@ -26,6 +26,7 @@
#include "util/glibc.h"
#include "util/log.h"
#include "util/patch.h"
#include "util/str.h"
#include "util/sys-info.h"
#include "options.h"
@@ -110,6 +111,21 @@ static void pro2hook_fs_redir_data(struct pro2hook_options *options)
log_assert(options);
if (options->game.data) {
char *machine_profile_path =
util_str_merge(options->game.data, "/Save/MachineProfile");
if (!util_fs_path_exists(machine_profile_path)) {
log_info(
"Machine profile path %s does not exist, creating",
machine_profile_path);
if (!util_fs_mkdir(machine_profile_path)) {
log_error("Creating directory %s failed", machine_profile_path);
}
}
free(machine_profile_path);
char *abs_path = util_fs_get_abs_path(options->game.data);
cnh_redir_add("/pro2", abs_path);
@@ -251,4 +267,4 @@ void pro2hook_trap_after_main(void)
LIB_MAIN_CONSTRUCTOR(pro2hook_constructor);
LIB_MAIN_DESTRUCTOR(pro2hook_destructor);
LIB_MAIN_TRAP_MAIN(pro2hook_trap_before_main, pro2hook_trap_after_main);
LIB_MAIN_TRAP_MAIN(pro2hook_trap_before_main, pro2hook_trap_after_main);