From b4273f9569cea2f23e82ba1db15c766d82757128 Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Mon, 10 Mar 2025 19:37:27 +0100 Subject: [PATCH] Fix regression introduced by latest release As it turns out, neither f_mkdir nor fs.c function create directories recursively, only the last one --- arm9/source/fs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arm9/source/fs.c b/arm9/source/fs.c index e693b7d2..2e248106 100644 --- a/arm9/source/fs.c +++ b/arm9/source/fs.c @@ -137,6 +137,7 @@ bool fileWrite(const void *buffer, const char *path, u32 size) return result == FR_OK && (u32)written == size; } case FR_NO_PATH: + // Only create the last dir in the hierarchy for(u32 i = 1; path[i] != 0; i++) if(path[i] == '/') { @@ -178,6 +179,7 @@ bool fileCopy(const char *pathSrc, const char *pathDst, bool replace, void *tmpB } else if (res == FR_NO_PATH) { + // Only create the last dir in the hierarchy const char *c; for (c = pathDst + strlen(pathDst); *c != '/' && c >= pathDst; --c); if (c >= pathDst && c - pathDst <= FF_MAX_LFN && *c != '\0') @@ -446,6 +448,11 @@ static bool backupEssentialFiles(void) sprintf(pathStart, "backups/%08lX/", deviceID); char fullPath[0x80]; + // Since the other funcs in this file don't create directories recursively (only the last one), + // and nor does f_mkdir, create the directories anyway and ignore the result + f_mkdir("backups"); + f_mkdir(pathStart); + bool ok = true; sprintf(fullPath, "%sHWCAL0.dat", pathStart); ok = ok && fileCopy("nand:/ro/sys/HWCAL0.dat", fullPath, false, fileCopyBuffer, sz);