BAHAHAHAHAAHAHAHhh

This commit is contained in:
Arisotura 2021-10-02 03:47:42 +02:00
parent f64d0ba320
commit a25b4549a2
3 changed files with 46 additions and 4 deletions

View File

@ -56,7 +56,8 @@ FATStorage::FATStorage()
FATStorage::~FATStorage()
{
//
printf("SAVING DLDI SHIT\n");
Save("dldi");
}
@ -298,7 +299,7 @@ void FATStorage::ExportDirectory(std::string path, std::string outbase, int leve
fDIR dir;
FILINFO info;
FRESULT res;
printf("EXPORTING DIRECTORY %s (base %s level %d)\n", path.c_str(), outbase.c_str(), level);
std::string fullpath = "0:/" + path;
res = f_opendir(&dir, fullpath.c_str());
if (res != FR_OK) return;
@ -332,7 +333,7 @@ void FATStorage::ExportDirectory(std::string path, std::string outbase, int leve
else
{
bool doexport = false;
printf("- FILE %s\n", fullpath.c_str());
if (FileIndex.count(fullpath) < 1)
{
doexport = true;
@ -866,3 +867,39 @@ bool FATStorage::Build(const char* sourcedir, u64 size, const char* filename)
return true;
}
bool FATStorage::Save(std::string sourcedir)
{
FF_File = Platform::OpenLocalFile(FilePath.c_str(), "r+b");
if (!FF_File)
{
return false;
}
FF_FileSize = FileSize;
ff_disk_open(FF_ReadStorage, FF_WriteStorage, (LBA_t)(FileSize>>9));
FRESULT res;
FATFS fs;
res = f_mount(&fs, "0:", 1);
if (res != FR_OK)
{
ff_disk_close();
fclose(FF_File);
FF_File = nullptr;
return false;
}
ExportChanges("dldi");
SaveIndex();
f_unmount("0:");
ff_disk_close();
fclose(FF_File);
FF_File = nullptr;
return true;
}

View File

@ -58,7 +58,9 @@ private:
void CleanupDirectory(std::string path, int level);
bool ImportFile(std::string path, std::string in);
bool BuildSubdirectory(const char* sourcedir, const char* path, int level);
bool Build(const char* sourcedir, u64 size, const char* filename);
bool Save(std::string sourcedir);
typedef struct
{

View File

@ -1178,7 +1178,10 @@ CartHomebrew::CartHomebrew(u8* rom, u32 len, u32 chipid) : CartCommon(rom, len,
CartHomebrew::~CartHomebrew()
{
if (SDFile) fclose(SDFile);
if (test) delete test;
if (test)
{
delete test;
}
}
void CartHomebrew::Reset()