From da7599d05c189ddc23f5e97f29606c6d98c48758 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Wed, 22 Nov 2017 03:13:20 +0100 Subject: [PATCH] Fix: Recognizing file locks due to alias mounts --- arm9/source/filesys/fsutil.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arm9/source/filesys/fsutil.c b/arm9/source/filesys/fsutil.c index 686da53..ee837a1 100644 --- a/arm9/source/filesys/fsutil.c +++ b/arm9/source/filesys/fsutil.c @@ -101,11 +101,13 @@ bool SetupBonusDrive(void) { bool FileUnlock(const char* path) { FIL file; + FRESULT res; + if (!(DriveType(path) & DRV_FAT)) return true; // can't really check this - if (fx_open(&file, path, FA_READ | FA_OPEN_EXISTING) != FR_OK) { + if ((res = fx_open(&file, path, FA_READ | FA_OPEN_EXISTING)) != FR_OK) { char pathstr[32 + 1]; TruncateString(pathstr, path, 32, 8); - if (GetMountState() && (strncasecmp(path, GetMountPath(), 256) == 0) && + if (GetMountState() && (res == FR_LOCKED) && (ShowPrompt(true, "%s\nFile is currently mounted.\nUnmount to unlock?", pathstr))) { InitImgFS(NULL); if (fx_open(&file, path, FA_READ | FA_OPEN_EXISTING) != FR_OK) @@ -113,6 +115,7 @@ bool FileUnlock(const char* path) { } else return false; } fx_close(&file); + return true; }