forked from Mirror/GodMode9
Vastly speed up boot times
This also improves f_getfree handling (prevents it where possible)
This commit is contained in:
parent
9882b68a31
commit
e36b2c347f
@ -425,24 +425,17 @@ bool PathMoveCopyRec(char* dest, char* orig, u32* flags, bool move) {
|
||||
ShowProgress(0, 0, orig); // reinit progress bar
|
||||
}
|
||||
|
||||
fsize = fvx_size(&ofile);
|
||||
if (!to_virtual && (GetFreeSpace(dest) < fsize)) {
|
||||
if (!silent) ShowPrompt(false, "%s\nError: Not enough space in drive", deststr);
|
||||
fvx_close(&ofile);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fvx_open(&dfile, dest, FA_WRITE | FA_CREATE_ALWAYS) != FR_OK) {
|
||||
if (!silent) ShowPrompt(false, "%s\nError: Cannot open destination file", deststr);
|
||||
fvx_close(&ofile);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (to_virtual && (fvx_size(&dfile) < fsize)) {
|
||||
if (!silent) ShowPrompt(false, "%s\nError: Not enough virtual space", deststr);
|
||||
fvx_close(&ofile);
|
||||
fvx_close(&dfile);
|
||||
return false;
|
||||
ret = true; // destination file exists by now, so we need to handle deletion
|
||||
fsize = fvx_size(&ofile); // check space via cluster preallocation
|
||||
if ((fvx_lseek(&dfile, fsize) != FR_OK) || (fvx_sync(&dfile) != FR_OK)) {
|
||||
if (!silent) ShowPrompt(false, "%s\nError: Not enough space available", deststr);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
fvx_lseek(&dfile, 0);
|
||||
@ -450,7 +443,6 @@ bool PathMoveCopyRec(char* dest, char* orig, u32* flags, bool move) {
|
||||
fvx_lseek(&ofile, 0);
|
||||
fvx_sync(&ofile);
|
||||
|
||||
ret = true;
|
||||
if (flags && (*flags & CALC_SHA)) sha_init(SHA256_MODE);
|
||||
for (u64 pos = 0; (pos < fsize) && ret; pos += MAIN_BUFFER_SIZE) {
|
||||
UINT bytes_read = 0;
|
||||
|
@ -63,8 +63,10 @@ FRESULT fvx_close (FIL* fp) {
|
||||
FRESULT fvx_lseek (FIL* fp, FSIZE_t ofs) {
|
||||
#if _VFIL_ENABLED
|
||||
if (fp->obj.fs == NULL) {
|
||||
fp->fptr = ofs;
|
||||
return FR_OK;
|
||||
if (fvx_size(fp) >= ofs) {
|
||||
fp->fptr = ofs;
|
||||
return FR_OK;
|
||||
} else return FR_DENIED;
|
||||
}
|
||||
#endif
|
||||
return f_lseek( fp, ofs );
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "timer.h"
|
||||
#include "power.h"
|
||||
#include "rtc.h"
|
||||
#include "i2c.h"
|
||||
#include QLZ_SPLASH_H
|
||||
|
||||
#define N_PANES 2
|
||||
@ -161,22 +160,27 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
state_prev = state_curr;
|
||||
}
|
||||
|
||||
// top bar - current path & free/total storage
|
||||
// top bar - current path & free/total storage (or clock)
|
||||
DrawRectangle(TOP_SCREEN, 0, 0, SCREEN_WIDTH_TOP, 12, COLOR_TOP_BAR);
|
||||
if (strncmp(curr_path, "", 256) != 0) {
|
||||
if (*curr_path) TruncateString(tempstr, curr_path, len_path / FONT_WIDTH_EXT, 8);
|
||||
else snprintf(tempstr, 16, "[root]");
|
||||
DrawStringF(TOP_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, tempstr);
|
||||
bool show_time = true;
|
||||
#ifdef SHOW_FREE
|
||||
if (*curr_path) {
|
||||
char bytestr0[32];
|
||||
char bytestr1[32];
|
||||
TruncateString(tempstr, curr_path, len_path / FONT_WIDTH_EXT, 8);
|
||||
DrawStringF(TOP_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, tempstr);
|
||||
DrawStringF(TOP_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", "LOADING...");
|
||||
// DrawStringF(TOP_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", "LOADING...");
|
||||
FormatBytes(bytestr0, GetFreeSpace(curr_path));
|
||||
FormatBytes(bytestr1, GetTotalSpace(curr_path));
|
||||
snprintf(tempstr, 64, "%s/%s", bytestr0, bytestr1);
|
||||
DrawStringF(TOP_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", tempstr);
|
||||
} else {
|
||||
show_time = false;
|
||||
}
|
||||
#endif
|
||||
if (show_time) {
|
||||
char timestr[32];
|
||||
GetTimeString(timestr, false);
|
||||
DrawStringF(TOP_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "[root]");
|
||||
DrawStringF(TOP_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", timestr);
|
||||
}
|
||||
|
||||
@ -1627,16 +1631,13 @@ u32 GodMode() {
|
||||
}
|
||||
|
||||
SplashInit();
|
||||
u64 timer = timer_start(); // show splash for at least 1 sec
|
||||
u64 timer = timer_start(); // show splash
|
||||
|
||||
InitSDCardFS();
|
||||
AutoEmuNandBase(true);
|
||||
InitNandCrypto(true);
|
||||
InitExtFS();
|
||||
|
||||
// this takes long - do it while splash is displayed
|
||||
GetFreeSpace("0:");
|
||||
|
||||
GetDirContents(current_dir, "");
|
||||
clipboard->n_entries = 0;
|
||||
memset(panedata, 0x00, 0x10000);
|
||||
@ -1654,7 +1655,7 @@ u32 GodMode() {
|
||||
}
|
||||
}
|
||||
|
||||
while(timer_sec( timer ) < 1); // show splash for at least 1 sec
|
||||
while (timer_msec( timer ) < 500); // show splash for at least 0.5 sec
|
||||
ClearScreenF(true, true, COLOR_STD_BG); // clear splash
|
||||
|
||||
while (true) { // this is the main loop
|
||||
|
Loading…
x
Reference in New Issue
Block a user