Skip to content

Commit

Permalink
Add missing fileRead checks
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraWright committed Sep 6, 2017
1 parent d37bff5 commit 2af6ef4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions stage2/arm9/source/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2af6ef4

Please sign in to comment.