Minor stuff
This commit is contained in:
parent
c43960f7d4
commit
5ded6aa619
16
source/fs.c
16
source/fs.c
@ -40,9 +40,10 @@ void unmountCtrNand(void)
|
|||||||
u32 fileRead(void *dest, const char *path, u32 maxSize)
|
u32 fileRead(void *dest, const char *path, u32 maxSize)
|
||||||
{
|
{
|
||||||
FIL file;
|
FIL file;
|
||||||
u32 ret = 0;
|
u32 ret;
|
||||||
|
|
||||||
if(f_open(&file, path, FA_READ) == FR_OK)
|
if(f_open(&file, path, FA_READ) != FR_OK) ret = 0;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
u32 size = f_size(&file);
|
u32 size = f_size(&file);
|
||||||
if(size <= maxSize)
|
if(size <= maxSize)
|
||||||
@ -98,13 +99,14 @@ u32 firmRead(void *dest)
|
|||||||
concatenateStrings(path, "/content");
|
concatenateStrings(path, "/content");
|
||||||
|
|
||||||
DIR dir;
|
DIR dir;
|
||||||
FILINFO info;
|
|
||||||
|
|
||||||
u32 firmVersion = 0xFFFFFFFF,
|
u32 firmVersion = 0xFFFFFFFF,
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
if(f_opendir(&dir, path) == FR_OK)
|
if(f_opendir(&dir, path) == FR_OK)
|
||||||
{
|
{
|
||||||
|
FILINFO info;
|
||||||
|
|
||||||
//Parse the target directory
|
//Parse the target directory
|
||||||
while(f_readdir(&dir, &info) == FR_OK && info.fname[0] != 0)
|
while(f_readdir(&dir, &info) == FR_OK && info.fname[0] != 0)
|
||||||
{
|
{
|
||||||
@ -114,13 +116,7 @@ u32 firmRead(void *dest)
|
|||||||
//Multiple cxis were found
|
//Multiple cxis were found
|
||||||
if(firmVersion != 0xFFFFFFFF) ret = 1;
|
if(firmVersion != 0xFFFFFFFF) ret = 1;
|
||||||
|
|
||||||
//Convert the .app name to an integer
|
u32 tempVersion = hexAtoi(info.altname, 8);
|
||||||
u32 tempVersion = 0;
|
|
||||||
for(char *tmp = info.altname; *tmp != '.'; tmp++)
|
|
||||||
{
|
|
||||||
tempVersion <<= 4;
|
|
||||||
tempVersion += *tmp > '9' ? *tmp - 'A' + 10 : *tmp - '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIRM is equal or newer than 11.0
|
//FIRM is equal or newer than 11.0
|
||||||
if(tempVersion >= (ISN3DS ? 0x21 : 0x52)) ret = tempVersion <= (ISN3DS ? 0x26 : 0x56) ? 5 : 2;
|
if(tempVersion >= (ISN3DS ? 0x21 : 0x52)) ret = tempVersion <= (ISN3DS ? 0x26 : 0x56) ? 5 : 2;
|
||||||
|
@ -43,11 +43,22 @@ void concatenateStrings(char *destination, const char *source)
|
|||||||
void hexItoa(u32 number, char *out, u32 digits)
|
void hexItoa(u32 number, char *out, u32 digits)
|
||||||
{
|
{
|
||||||
const char hexDigits[] = "0123456789ABCDEF";
|
const char hexDigits[] = "0123456789ABCDEF";
|
||||||
u32 i = 0;
|
u32 i;
|
||||||
|
|
||||||
while(number > 0)
|
for(i = 0; number > 0; i++)
|
||||||
{
|
{
|
||||||
out[digits - 1 - i++] = hexDigits[number & 0xF];
|
out[digits - 1 - i] = hexDigits[number & 0xF];
|
||||||
number >>= 4;
|
number >>= 4;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 hexAtoi(const char *in, u32 digits)
|
||||||
|
{
|
||||||
|
u32 res = 0;
|
||||||
|
char *tmp = (char *)in;
|
||||||
|
|
||||||
|
for(u32 i = 0; i < digits && *tmp != 0; tmp++, i++)
|
||||||
|
res = (*tmp > '9' ? *tmp - 'A' + 10 : *tmp - '0') + (res << 4);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
@ -26,4 +26,5 @@
|
|||||||
|
|
||||||
u32 strlen(const char *string);
|
u32 strlen(const char *string);
|
||||||
void concatenateStrings(char *destination, const char *source);
|
void concatenateStrings(char *destination, const char *source);
|
||||||
void hexItoa(u32 number, char *out, u32 digits);
|
void hexItoa(u32 number, char *out, u32 digits);
|
||||||
|
u32 hexAtoi(const char *in, u32 digits);
|
Loading…
x
Reference in New Issue
Block a user