@@ -1432,12 +1432,16 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
14321432 screenshotPath = " fat:/_nds/nds-bootstrap/screenshots.tar" ;
14331433 }
14341434
1435- if (access (screenshotPath.c_str (), F_OK) != 0 ) {
1435+ if (getFileSize (screenshotPath.c_str ()) < 0x4BCC00 ) {
14361436 char buffer[2 ][0x100 ] = {{0 }};
14371437
14381438 consoleDemoInit ();
14391439 iprintf (" Creating screenshots.tar\n " );
1440- iprintf (" Please wait...\n " );
1440+ iprintf (" Please wait..." );
1441+
1442+ if (access (screenshotPath.c_str (), F_OK) == 0 ) {
1443+ remove (screenshotPath.c_str ());
1444+ }
14411445
14421446 FILE *headerFile = fopen (" nitro:/screenshotTarHeaders.bin" , " rb" );
14431447 if (headerFile) {
@@ -1460,6 +1464,11 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
14601464 }
14611465
14621466 consoleClear ();
1467+ if (getFileSize (screenshotPath.c_str ()) < 0x4BCC00 ) {
1468+ consoleDemoInit ();
1469+ iprintf (" Failed to create screenshots.tar" );
1470+ while (1 ) swiWaitForVBlank ();
1471+ }
14631472 igmText->currentScreenshot = 0 ;
14641473 } else {
14651474 FILE *screenshotFile = fopen (screenshotPath.c_str (), " rb" );
@@ -1723,12 +1732,16 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
17231732
17241733 screenshotPath = " fat:/_nds/nds-bootstrap/screenshots.tar" ;
17251734
1726- if (access (screenshotPath.c_str (), F_OK) != 0 ) {
1735+ if (getFileSize (screenshotPath.c_str ()) < 0x4BCC00 ) {
17271736 char buffer[2 ][0x100 ] = {{0 }};
17281737
17291738 consoleDemoInit ();
17301739 iprintf (" Creating screenshots.tar\n " );
1731- iprintf (" Please wait...\n " );
1740+ iprintf (" Please wait..." );
1741+
1742+ if (access (screenshotPath.c_str (), F_OK) == 0 ) {
1743+ remove (screenshotPath.c_str ());
1744+ }
17321745
17331746 FILE *headerFile = fopen (" nitro:/screenshotTarHeaders.bin" , " rb" );
17341747 if (headerFile) {
@@ -1751,6 +1764,11 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
17511764 }
17521765
17531766 consoleClear ();
1767+ if (getFileSize (screenshotPath.c_str ()) < 0x4BCC00 ) {
1768+ consoleDemoInit ();
1769+ iprintf (" Failed to create screenshots.tar" );
1770+ while (1 ) swiWaitForVBlank ();
1771+ }
17541772 igmText->currentScreenshot = 0 ;
17551773 } else {
17561774 FILE *screenshotFile = fopen (screenshotPath.c_str (), " rb" );
@@ -2112,19 +2130,15 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
21122130 ramDumpPath = " fat:/_nds/nds-bootstrap/ramDump.bin" ;
21132131 }
21142132
2115- if (access (ramDumpPath.c_str (), F_OK) != 0 ) {
2133+ if (getFileSize (ramDumpPath.c_str ()) < 0x02000000 ) {
21162134 consoleDemoInit ();
21172135 iprintf (" Allocating space for\n " );
21182136 iprintf (" creating a RAM dump.\n " );
2119- iprintf (" Please wait...\n " );
2120- /* printf("\n");
2121- if (conf->consoleModel >= 2) {
2122- iprintf("If this takes a while, press\n");
2123- iprintf("HOME, then press B.\n");
2124- } else {
2125- iprintf("If this takes a while, close\n");
2126- iprintf("the lid, and open it again.\n");
2127- } */
2137+ iprintf (" Please wait..." );
2138+
2139+ if (access (ramDumpPath.c_str (), F_OK) == 0 ) {
2140+ remove (ramDumpPath.c_str ());
2141+ }
21282142
21292143 FILE *ramDumpFile = fopen (ramDumpPath.c_str (), " wb" );
21302144 if (ramDumpFile) {
@@ -2134,18 +2148,27 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
21342148 }
21352149
21362150 consoleClear ();
2151+ if (getFileSize (ramDumpPath.c_str ()) < 0x02000000 ) {
2152+ consoleDemoInit ();
2153+ iprintf (" Failed to create RAM dump file." );
2154+ while (1 ) swiWaitForVBlank ();
2155+ }
21372156 }
21382157
21392158 apFixOverlaysPath = " sd:/_nds/nds-bootstrap/apFixOverlays.bin" ;
21402159 if (conf->gameOnFlashcard ) {
21412160 apFixOverlaysPath = " fat:/_nds/nds-bootstrap/apFixOverlays.bin" ;
21422161 }
21432162
2144- if (!conf->isDSiWare && access (apFixOverlaysPath.c_str (), F_OK) != 0 ) {
2163+ if (!conf->isDSiWare && getFileSize (apFixOverlaysPath.c_str ()) < 0x800000 ) {
21452164 consoleDemoInit ();
21462165 iprintf (" Allocating space for\n " );
21472166 iprintf (" AP-fixed overlays.\n " );
2148- iprintf (" Please wait...\n " );
2167+ iprintf (" Please wait..." );
2168+
2169+ if (access (apFixOverlaysPath.c_str (), F_OK) == 0 ) {
2170+ remove (apFixOverlaysPath.c_str ());
2171+ }
21492172
21502173 FILE *apFixOverlaysFile = fopen (apFixOverlaysPath.c_str (), " wb" );
21512174 if (apFixOverlaysFile) {
@@ -2155,14 +2178,24 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
21552178 }
21562179
21572180 consoleClear ();
2181+ if (getFileSize (apFixOverlaysPath.c_str ()) < 0x800000 ) {
2182+ consoleDemoInit ();
2183+ iprintf (" Failed to allocate space\n " );
2184+ iprintf (" for AP-fixed overlays." );
2185+ while (1 ) swiWaitForVBlank ();
2186+ }
21582187 }
21592188 } else {
21602189 ramDumpPath = " fat:/_nds/nds-bootstrap/ramDump.bin" ;
21612190
2162- if (access (ramDumpPath.c_str (), F_OK) != 0 ) {
2191+ if (getFileSize (ramDumpPath.c_str ()) < 0x800000 ) {
21632192 consoleDemoInit ();
21642193 iprintf (" Creating RAM dump file.\n " );
2165- iprintf (" Please wait...\n " );
2194+ iprintf (" Please wait..." );
2195+
2196+ if (access (ramDumpPath.c_str (), F_OK) == 0 ) {
2197+ remove (ramDumpPath.c_str ());
2198+ }
21662199
21672200 FILE *ramDumpFile = fopen (ramDumpPath.c_str (), " wb" );
21682201 if (ramDumpFile) {
@@ -2172,15 +2205,24 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
21722205 }
21732206
21742207 consoleClear ();
2208+ if (getFileSize (ramDumpPath.c_str ()) < 0x800000 ) {
2209+ consoleDemoInit ();
2210+ iprintf (" Failed to create RAM dump file." );
2211+ while (1 ) swiWaitForVBlank ();
2212+ }
21752213 }
21762214
21772215 apFixOverlaysPath = " fat:/_nds/nds-bootstrap/apFixOverlays.bin" ;
21782216
2179- if (!conf->isDSiWare && access (apFixOverlaysPath.c_str (), F_OK) != 0 ) {
2217+ if (!conf->isDSiWare && getFileSize (apFixOverlaysPath.c_str ()) < 0x800000 ) {
21802218 consoleDemoInit ();
21812219 iprintf (" Allocating space for\n " );
21822220 iprintf (" AP-fixed overlays.\n " );
2183- iprintf (" Please wait...\n " );
2221+ iprintf (" Please wait..." );
2222+
2223+ if (access (apFixOverlaysPath.c_str (), F_OK) == 0 ) {
2224+ remove (apFixOverlaysPath.c_str ());
2225+ }
21842226
21852227 FILE *apFixOverlaysFile = fopen (apFixOverlaysPath.c_str (), " wb" );
21862228 if (apFixOverlaysFile) {
@@ -2190,6 +2232,12 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) {
21902232 }
21912233
21922234 consoleClear ();
2235+ if (getFileSize (apFixOverlaysPath.c_str ()) < 0x800000 ) {
2236+ consoleDemoInit ();
2237+ iprintf (" Failed to allocate space\n " );
2238+ iprintf (" for AP-fixed overlays." );
2239+ while (1 ) swiWaitForVBlank ();
2240+ }
21932241 }
21942242 }
21952243
0 commit comments