mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Merge remote-tracking branch 'upstream/master' into bitmap-mode-and-cleanup
This commit is contained in:
commit
974cfcca11
@ -8,6 +8,7 @@
|
||||
#include "date.h"
|
||||
#include "file_browse.h"
|
||||
#include "font.h"
|
||||
#include "ndsheaderbanner.h"
|
||||
|
||||
#define copyBufSize 0x8000
|
||||
#define shaChunkSize 0x10000
|
||||
@ -105,6 +106,25 @@ bool calculateSHA1(const char *fileName, u8 *sha1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int trimNds(const char *fileName) {
|
||||
FILE *file = fopen(fileName, "rb");
|
||||
if(file) {
|
||||
sNDSHeaderExt ndsCardHeader;
|
||||
|
||||
fread(&ndsCardHeader, 1, sizeof(ndsCardHeader), file);
|
||||
fclose(file);
|
||||
|
||||
u32 romSize = ((ndsCardHeader.unitCode != 0) && (ndsCardHeader.twlRomSize > 0))
|
||||
? ndsCardHeader.twlRomSize : ndsCardHeader.romSize + 0x88;
|
||||
|
||||
truncate(fileName, romSize);
|
||||
|
||||
return romSize;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void dirCopy(const DirEntry &entry, int i, const char *destinationPath, const char *sourcePath) {
|
||||
std::vector<DirEntry> dirContents;
|
||||
dirContents.clear();
|
||||
|
||||
@ -23,6 +23,7 @@ extern std::string getBytes(int bytes);
|
||||
|
||||
extern off_t getFileSize(const char *fileName);
|
||||
extern bool calculateSHA1(const char *fileName, u8 *sha1);
|
||||
extern int trimNds(const char *fileName);
|
||||
extern int fcopy(const char *sourcePath, const char *destinationPath);
|
||||
void changeFileAttribs(const DirEntry *entry);
|
||||
|
||||
|
||||
@ -191,6 +191,7 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
||||
if(extension(entry->name, {"nds", "dsi", "ids", "app"})) {
|
||||
operations.push_back(FileOperation::mountNitroFS);
|
||||
operations.push_back(FileOperation::ndsInfo);
|
||||
operations.push_back(FileOperation::trimNds);
|
||||
} else if(extension(entry->name, {"sav", "sav1", "sav2", "sav3", "sav4", "sav5", "sav6", "sav7", "sav8", "sav9"})) {
|
||||
operations.push_back(FileOperation::restoreSave);
|
||||
} else if(extension(entry->name, {"img", "sd"})) {
|
||||
@ -236,6 +237,9 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
||||
case FileOperation::ndsInfo:
|
||||
font->print(3, row++, false, "Show NDS file info");
|
||||
break;
|
||||
case FileOperation::trimNds:
|
||||
font->print(3, row++, false, "Trim NDS file");
|
||||
break;
|
||||
case FileOperation::restoreSave:
|
||||
font->print(3, row++, false, "Restore save");
|
||||
break;
|
||||
@ -380,6 +384,9 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
||||
} case FileOperation::ndsInfo: {
|
||||
ndsInfo(entry->name.c_str());
|
||||
break;
|
||||
} case FileOperation::trimNds: {
|
||||
entry->size = trimNds(entry->name.c_str());
|
||||
break;
|
||||
} case FileOperation::showInfo: {
|
||||
changeFileAttribs(entry);
|
||||
break;
|
||||
|
||||
@ -38,6 +38,8 @@ enum class FileOperation {
|
||||
bootFile,
|
||||
bootstrapFile,
|
||||
mountNitroFS,
|
||||
ndsInfo,
|
||||
trimNds,
|
||||
mountImg,
|
||||
restoreSave,
|
||||
showInfo,
|
||||
@ -45,7 +47,6 @@ enum class FileOperation {
|
||||
copyFatOut,
|
||||
calculateSHA1,
|
||||
hexEdit,
|
||||
ndsInfo,
|
||||
};
|
||||
|
||||
bool extension(const std::string &filename, const std::vector<std::string> &extensions);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user