mirror of
https://github.com/rvtr/TDT.git
synced 2025-10-31 13:51:07 -04:00
Allow (un)installing non-preinstalled system apps
This commit is contained in:
parent
cfbbd949d8
commit
af3408a8aa
@ -112,12 +112,12 @@ static bool _checkSdSpace(unsigned long long size)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _checkDsiSpace(unsigned long long size)
|
||||
static bool _checkDsiSpace(unsigned long long size, bool systemApp)
|
||||
{
|
||||
iprintf("Enough room on DSi?...");
|
||||
swiWaitForVBlank();
|
||||
|
||||
if (getDsiFree() < size)
|
||||
if ((systemApp ? getDsiRealFree() : getDsiFree()) < size)
|
||||
{
|
||||
iprintf("\x1B[31m"); //red
|
||||
iprintf("No\n");
|
||||
@ -397,24 +397,40 @@ bool install(char* fpath, bool systemTitle)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!sdnandMode &&
|
||||
(h->tid_high == 0x00030005 ||
|
||||
h->tid_high == 0x00030015))
|
||||
//blacklisted titles
|
||||
{
|
||||
iprintf("\x1B[31m"); //red
|
||||
iprintf("Error: ");
|
||||
iprintf("\x1B[33m"); //yellow
|
||||
iprintf("This title cannot be\ninstalled to SysNAND.\n");
|
||||
iprintf("\x1B[47m"); //white
|
||||
goto error;
|
||||
//tid without region
|
||||
u32 tidLow = (h->tid_low & 0xFFFFFF00);
|
||||
if (!sdnandMode && (
|
||||
(h->tid_high == 0x00030005 && (
|
||||
tidLow == 0x484e4400 || // DS Download Play
|
||||
tidLow == 0x484e4500 || // PictoChat
|
||||
tidLow == 0x484e4900 || // Nintendo DSi Camera
|
||||
tidLow == 0x484e4b00 // Nintendo DSi Sound
|
||||
)) || (h->tid_high == 0x00030015 && (
|
||||
tidLow == 0x484e4200 || // System Settings
|
||||
tidLow == 0x484e4600 // Nintendo DSi Shop
|
||||
))))
|
||||
{
|
||||
iprintf("\x1B[31m"); //red
|
||||
iprintf("Error: ");
|
||||
iprintf("\x1B[33m"); //yellow
|
||||
iprintf("This title cannot be\ninstalled to SysNAND.\n");
|
||||
iprintf("\x1B[47m"); //white
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
//confirmation message
|
||||
{
|
||||
char str[] = "Are you sure you want to install\n";
|
||||
char* msg = (char*)malloc(strlen(str) + strlen(fpath) + 8);
|
||||
sprintf(msg, "%s%s\n", str, fpath);
|
||||
|
||||
const char system[] = "\x1B[41mWARNING:\x1B[47m This is a system app,\ninstalling it is potentially\nmore risky than regular DSiWare.\n\x1B[33m";
|
||||
const char areYouSure[] = "Are you sure you want to install\n";
|
||||
char* msg = (char*)malloc(strlen(system) + strlen(areYouSure) + strlen(fpath) + 2);
|
||||
if(sdnandMode || h->tid_high == 0x00030004)
|
||||
sprintf(msg, "%s%s?\n", areYouSure, fpath);
|
||||
else
|
||||
sprintf(msg, "%s%s%s?\n", system, areYouSure, fpath);
|
||||
|
||||
bool choice = choiceBox(msg);
|
||||
free(msg);
|
||||
|
||||
@ -475,20 +491,17 @@ bool install(char* fpath, bool systemTitle)
|
||||
fixHeader = true;
|
||||
}
|
||||
|
||||
//skip nand check if system title
|
||||
if (h->tid_high != 0x00030015)
|
||||
//check that there's space on nand
|
||||
if (!_checkDsiSpace(installSize, (h->tid_high != 0x00030004)))
|
||||
{
|
||||
if (!_checkDsiSpace(installSize))
|
||||
if (sdnandMode && choicePrint("Install as system title?"))
|
||||
{
|
||||
if (sdnandMode && choicePrint("Install as system title?"))
|
||||
{
|
||||
h->tid_high = 0x00030015;
|
||||
fixHeader = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
h->tid_high = 0x00030015;
|
||||
fixHeader = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -533,6 +533,15 @@ unsigned long long getDsiFree()
|
||||
return size;
|
||||
}
|
||||
|
||||
unsigned long long getDsiRealFree()
|
||||
{
|
||||
struct statvfs st;
|
||||
if (statvfs(sdnandMode ? "sd:/" : "nand:/", &st) == 0)
|
||||
return st.f_bsize * st.f_bavail;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 getDsiClusterSize()
|
||||
{
|
||||
struct statvfs st;
|
||||
|
||||
@ -42,6 +42,7 @@ unsigned long long getSDCardFree();
|
||||
//internal storage
|
||||
unsigned long long getDsiSize();
|
||||
unsigned long long getDsiFree();
|
||||
unsigned long long getDsiRealFree();
|
||||
u32 getDsiClusterSize();
|
||||
#define getDsiUsed() (getDSIStorageSize() - getDSIStorageFree())
|
||||
|
||||
|
||||
@ -79,16 +79,12 @@ static void generateList(Menu* m)
|
||||
{
|
||||
if (!m) return;
|
||||
|
||||
const int NUM_OF_DIRS = sdnandMode ? 3 : 1;
|
||||
const char* sdnandDirs[] = {
|
||||
const int NUM_OF_DIRS = 3;
|
||||
const char* dirs[] = {
|
||||
"00030004",
|
||||
"00030005",
|
||||
"00030015"
|
||||
};
|
||||
const char* nandDirs[] = {
|
||||
"00030004"
|
||||
};
|
||||
const char** dirs = sdnandMode ? sdnandDirs : nandDirs;
|
||||
|
||||
//Reset menu
|
||||
clearMenu(m);
|
||||
@ -115,6 +111,21 @@ static void generateList(Menu* m)
|
||||
if (strcmp(".", ent->d_name) == 0 || strcmp("..", ent->d_name) == 0)
|
||||
continue;
|
||||
|
||||
//blacklisted titles
|
||||
if (!sdnandMode && (
|
||||
(i == 1 && (
|
||||
strncmp(ent->d_name, "484e44", 6) == 0 || // DS Download Play
|
||||
strncmp(ent->d_name, "484e45", 6) == 0 || // PictoChat
|
||||
strncmp(ent->d_name, "484e49", 6) == 0 || // Nintendo DSi Camera
|
||||
strncmp(ent->d_name, "484e4b", 6) == 0 // Nintendo DSi Sound
|
||||
)) || (i == 2 && (
|
||||
strncmp(ent->d_name, "484e42", 6) == 0 || // System Settings
|
||||
strncmp(ent->d_name, "484e46", 6) == 0 // Nintendo DSi Shop
|
||||
))))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ent->d_type == DT_DIR)
|
||||
{
|
||||
//scan content folder /title/XXXXXXXX/content
|
||||
|
||||
Loading…
Reference in New Issue
Block a user