fix(installer): recursively create app directories for fresh systems

On clean PS5 systems with no prior apps or games installed, /user/app does not exist yet, causing direct mkdir() on /user/app/<title_id> to fail with ENOENT (errno: 2).

Use recursive mkdir_p to create the required directory tree (/user/app/<title_id>/sce_sys).

Resolves #108
This commit is contained in:
najdek committed 2026-10-11 23:12:30 +02:00
1 parent aedf1bf31a
commit 37f5b3b6cf
1 file changed
+25 -9
+25 -9
View File
@@ -35,6 +35,29 @@ int sceAppInstUtilTerminate(void);
int sceAppInstUtilAppInstallAll(void *);
int sceAppInstUtilAppUnInstall(const char *);
static int mkdir_p(const char *path, mode_t mode) {
char tmp[256];
snprintf(tmp, sizeof(tmp), "%s", path);
size_t len = strlen(tmp);
if (len == 0)
return 0;
if (tmp[len - 1] == '/')
tmp[len - 1] = '\0';
for (char *p = tmp + 1; *p; p++) {
if (*p == '/') {
*p = '\0';
if (mkdir(tmp, mode) != 0 && errno != EEXIST) {
return -1;
}
*p = '/';
}
}
if (mkdir(tmp, mode) != 0 && errno != EEXIST) {
return -1;
}
return 0;
}
static int install_file(const char *path, const uint8_t *data, size_t size) {
FILE *f;
if (!(f = fopen(path, "w"))) {
@@ -138,17 +161,10 @@ int pldmgr_install_app_if_needed(void) {
return -1;
}
if (mkdir(base_dir, 0755) && errno != EEXIST) {
pldmgr_log("[PLDMGR] Failed to create app dir: %s (errno: %d)\n", base_dir,
errno);
sceAppInstUtilTerminate();
return -1;
}
char sce_sys_dir[256];
snprintf(sce_sys_dir, sizeof(sce_sys_dir), "/user/app/%s/sce_sys", title_id);
if (mkdir(sce_sys_dir, 0755) && errno != EEXIST) {
pldmgr_log("[PLDMGR] Failed to create sce_sys dir: %s (errno: %d)\n",
if (mkdir_p(sce_sys_dir, 0755) != 0) {
pldmgr_log("[PLDMGR] Failed to create app dir: %s (errno: %d)\n",
sce_sys_dir, errno);
sceAppInstUtilTerminate();
return -1;