mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-24 14:49:53 -06:00
DLDI/SD folder-sync apparatus (#1251)
guess we can finally have DLDI that isn't obtuse
This commit is contained in:
@ -52,7 +52,10 @@ bool Init(FILE* nandfile, u8* es_keyY)
|
||||
if (!nandfile)
|
||||
return false;
|
||||
|
||||
ff_disk_open(FF_ReadNAND, FF_WriteNAND);
|
||||
fseek(nandfile, 0, SEEK_END);
|
||||
u64 nandlen = ftell(nandfile);
|
||||
|
||||
ff_disk_open(FF_ReadNAND, FF_WriteNAND, (LBA_t)(nandlen>>9));
|
||||
|
||||
FRESULT res;
|
||||
res = f_mount(&CurFS, "0:", 0);
|
||||
@ -438,7 +441,7 @@ bool ESDecrypt(u8* data, u32 len)
|
||||
|
||||
void ReadHardwareInfo(u8* dataS, u8* dataN)
|
||||
{
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
FRESULT res;
|
||||
u32 nread;
|
||||
|
||||
@ -460,11 +463,11 @@ void ReadHardwareInfo(u8* dataS, u8* dataN)
|
||||
|
||||
void ReadUserData(u8* data)
|
||||
{
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
FRESULT res;
|
||||
u32 nread;
|
||||
|
||||
FIL f1, f2;
|
||||
FF_FIL f1, f2;
|
||||
int v1, v2;
|
||||
|
||||
res = f_open(&f1, "0:/shared1/TWLCFG0.dat", FA_OPEN_EXISTING | FA_READ);
|
||||
@ -516,7 +519,7 @@ void PatchTSC()
|
||||
char filename[64];
|
||||
sprintf(filename, "0:/shared1/TWLCFG%d.dat", i);
|
||||
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
res = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ | FA_WRITE);
|
||||
if (res != FR_OK)
|
||||
{
|
||||
@ -554,8 +557,8 @@ void PatchTSC()
|
||||
|
||||
void debug_listfiles(const char* path)
|
||||
{
|
||||
DIR dir;
|
||||
FILINFO info;
|
||||
FF_DIR dir;
|
||||
FF_FILINFO info;
|
||||
FRESULT res;
|
||||
|
||||
res = f_opendir(&dir, path);
|
||||
@ -564,8 +567,8 @@ void debug_listfiles(const char* path)
|
||||
for (;;)
|
||||
{
|
||||
res = f_readdir(&dir, &info);
|
||||
if (res != FR_OK) return;
|
||||
if (!info.fname[0]) return;
|
||||
if (res != FR_OK) break;
|
||||
if (!info.fname[0]) break;
|
||||
|
||||
char fullname[512];
|
||||
sprintf(fullname, "%s/%s", path, info.fname);
|
||||
@ -582,7 +585,7 @@ void debug_listfiles(const char* path)
|
||||
|
||||
bool ImportFile(const char* path, const char* in)
|
||||
{
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
FILE* fin;
|
||||
FRESULT res;
|
||||
|
||||
@ -601,14 +604,14 @@ bool ImportFile(const char* path, const char* in)
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 buf[0x200];
|
||||
for (u32 i = 0; i < len; i += 0x200)
|
||||
u8 buf[0x1000];
|
||||
for (u32 i = 0; i < len; i += 0x1000)
|
||||
{
|
||||
u32 blocklen;
|
||||
if ((i + 0x200) > len)
|
||||
if ((i + 0x1000) > len)
|
||||
blocklen = len - i;
|
||||
else
|
||||
blocklen = 0x200;
|
||||
blocklen = 0x1000;
|
||||
|
||||
u32 nwrite;
|
||||
fread(buf, blocklen, 1, fin);
|
||||
@ -623,7 +626,7 @@ bool ImportFile(const char* path, const char* in)
|
||||
|
||||
bool ExportFile(const char* path, const char* out)
|
||||
{
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
FILE* fout;
|
||||
FRESULT res;
|
||||
|
||||
@ -640,14 +643,14 @@ bool ExportFile(const char* path, const char* out)
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 buf[0x200];
|
||||
for (u32 i = 0; i < len; i += 0x200)
|
||||
u8 buf[0x1000];
|
||||
for (u32 i = 0; i < len; i += 0x1000)
|
||||
{
|
||||
u32 blocklen;
|
||||
if ((i + 0x200) > len)
|
||||
if ((i + 0x1000) > len)
|
||||
blocklen = len - i;
|
||||
else
|
||||
blocklen = 0x200;
|
||||
blocklen = 0x1000;
|
||||
|
||||
u32 nread;
|
||||
f_read(&file, buf, blocklen, &nread);
|
||||
@ -662,7 +665,7 @@ bool ExportFile(const char* path, const char* out)
|
||||
|
||||
void RemoveFile(const char* path)
|
||||
{
|
||||
FILINFO info;
|
||||
FF_FILINFO info;
|
||||
FRESULT res = f_stat(path, &info);
|
||||
if (res != FR_OK) return;
|
||||
|
||||
@ -674,8 +677,8 @@ void RemoveFile(const char* path)
|
||||
|
||||
void RemoveDir(const char* path)
|
||||
{
|
||||
DIR dir;
|
||||
FILINFO info;
|
||||
FF_DIR dir;
|
||||
FF_FILINFO info;
|
||||
FRESULT res;
|
||||
|
||||
res = f_stat(path, &info);
|
||||
@ -731,7 +734,7 @@ u32 GetTitleVersion(u32 category, u32 titleid)
|
||||
FRESULT res;
|
||||
char path[256];
|
||||
sprintf(path, "0:/title/%08x/%08x/content/title.tmd", category, titleid);
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);
|
||||
if (res != FR_OK)
|
||||
return 0xFFFFFFFF;
|
||||
@ -749,7 +752,7 @@ u32 GetTitleVersion(u32 category, u32 titleid)
|
||||
void ListTitles(u32 category, std::vector<u32>& titlelist)
|
||||
{
|
||||
FRESULT res;
|
||||
DIR titledir;
|
||||
FF_DIR titledir;
|
||||
char path[256];
|
||||
|
||||
sprintf(path, "0:/title/%08x", category);
|
||||
@ -762,7 +765,7 @@ void ListTitles(u32 category, std::vector<u32>& titlelist)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
FILINFO info;
|
||||
FF_FILINFO info;
|
||||
f_readdir(&titledir, &info);
|
||||
if (!info.fname[0])
|
||||
break;
|
||||
@ -779,7 +782,7 @@ void ListTitles(u32 category, std::vector<u32>& titlelist)
|
||||
continue;
|
||||
|
||||
sprintf(path, "0:/title/%08x/%08x/content/%08x.app", category, titleid, version);
|
||||
FILINFO appinfo;
|
||||
FF_FILINFO appinfo;
|
||||
res = f_stat(path, &appinfo);
|
||||
if (res != FR_OK)
|
||||
continue;
|
||||
@ -814,7 +817,7 @@ void GetTitleInfo(u32 category, u32 titleid, u32& version, NDSHeader* header, ND
|
||||
|
||||
char path[256];
|
||||
sprintf(path, "0:/title/%08x/%08x/content/%08x.app", category, titleid, version);
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);
|
||||
if (res != FR_OK)
|
||||
return;
|
||||
@ -842,7 +845,7 @@ void GetTitleInfo(u32 category, u32 titleid, u32& version, NDSHeader* header, ND
|
||||
|
||||
bool CreateTicket(const char* path, u32 titleid0, u32 titleid1, u8 version)
|
||||
{
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
FRESULT res;
|
||||
u32 nwrite;
|
||||
|
||||
@ -908,7 +911,7 @@ bool CreateSaveFile(const char* path, u32 len)
|
||||
if (len == 0x4000) totsec16 = 27;
|
||||
else totsec16 = len >> 9;
|
||||
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
FRESULT res;
|
||||
u32 nwrite;
|
||||
|
||||
@ -966,11 +969,11 @@ bool ImportTitle(const char* appfile, u8* tmd, bool readonly)
|
||||
printf("Title ID: %08x/%08x\n", titleid0, titleid1);
|
||||
|
||||
FRESULT res;
|
||||
DIR ticketdir;
|
||||
FILINFO info;
|
||||
FF_DIR ticketdir;
|
||||
FF_FILINFO info;
|
||||
|
||||
char fname[128];
|
||||
FIL file;
|
||||
FF_FIL file;
|
||||
u32 nwrite;
|
||||
|
||||
// ticket
|
||||
|
Reference in New Issue
Block a user