diff --git a/stage2/arm9/source/fs.c b/stage2/arm9/source/fs.c index 9b3d7ab..2514dbb 100644 --- a/stage2/arm9/source/fs.c +++ b/stage2/arm9/source/fs.c @@ -26,16 +26,17 @@ bool mountCtrNand(void) u32 fileRead(void *dest, const char *path, u32 size, u32 maxSize) { FIL file; + FRESULT result = FR_OK; u32 ret = 0; if(f_open(&file, path, FA_READ) != FR_OK) return ret; if(!size) size = f_size(&file); if(!maxSize || size <= maxSize) - f_read(&file, dest, size, (unsigned int *)&ret); - f_close(&file); + result = f_read(&file, dest, size, (unsigned int *)&ret); + result |= f_close(&file); - return ret; + return result == FR_OK ? ret : 0; } bool fileWrite(const void *buffer, const char *path, u32 size)