Support file paths up to 256 in length, allows for sorting in directories

This commit is contained in:
Travis Burtrum 2021-10-23 00:27:37 -04:00
parent 1fb85d8afe
commit 7f04ea7c58

View File

@ -63,6 +63,8 @@
#define MAX_LIST 20 #define MAX_LIST 20
#define MAX_SUPPORTED_PATH_LEN 256
struct glyph struct glyph
{ {
int xoff; int xoff;
@ -189,7 +191,7 @@ int save_after_reboot = 0;
unsigned char cartID[4]; unsigned char cartID[4];
char curr_dirname[64]; char curr_dirname[64];
char pwd[64]; char pwd[64];
TCHAR rom_filename[256]; TCHAR rom_filename[MAX_SUPPORTED_PATH_LEN];
u32 rom_buff[128]; //rom buffer u32 rom_buff[128]; //rom buffer
u8 *rom_buff8; //rom buffer u8 *rom_buff8; //rom buffer
@ -915,7 +917,7 @@ void clearScreen(display_context_t disp)
void romInfoScreen(display_context_t disp, u8 *buff, int silent) void romInfoScreen(display_context_t disp, u8 *buff, int silent)
{ {
TCHAR filename[64]; TCHAR filename[MAX_SUPPORTED_PATH_LEN];
sprintf(filename, "%s", buff); sprintf(filename, "%s", buff);
int swapped = 0; int swapped = 0;
@ -1338,7 +1340,7 @@ void loadrom(display_context_t disp, u8 *buff, int fast)
printText("Loading ROM, Please wait:", 3, 4, disp); printText("Loading ROM, Please wait:", 3, 4, disp);
TCHAR filename[64]; TCHAR filename[MAX_SUPPORTED_PATH_LEN];
sprintf(filename, "%s", buff); sprintf(filename, "%s", buff);
FRESULT result; FRESULT result;
@ -1516,7 +1518,7 @@ void loadrom(display_context_t disp, u8 *buff, int fast)
int backupSaveData(display_context_t disp) int backupSaveData(display_context_t disp)
{ {
//backup cart-save on sd after reboot //backup cart-save on sd after reboot
TCHAR config_file_path[32]; TCHAR config_file_path[MAX_SUPPORTED_PATH_LEN];
sprintf(config_file_path, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path); sprintf(config_file_path, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path);
u8 save_format; u8 save_format;
@ -1626,7 +1628,7 @@ int saveTypeFromSd(display_context_t disp, char *rom_name, int stype)
TRACE(disp, rom_filename); TRACE(disp, rom_filename);
const char* save_type_extension = saveTypeToExtension(stype, ext_type); const char* save_type_extension = saveTypeToExtension(stype, ext_type);
TCHAR fname[256] = {0}; TCHAR fname[MAX_SUPPORTED_PATH_LEN] = {0};
int save_count = 0; //TODO: once this crosses 9999 bad infinite-loop type things happen, look into that one day int save_count = 0; //TODO: once this crosses 9999 bad infinite-loop type things happen, look into that one day
FRESULT result; FRESULT result;
FILINFO fnoba; FILINFO fnoba;
@ -1728,7 +1730,7 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
{ {
//after reset create new savefile //after reset create new savefile
const char* save_type_extension = saveTypeToExtension(stype, ext_type); const char* save_type_extension = saveTypeToExtension(stype, ext_type);
TCHAR fname[256]; //TODO: change filename buffers to 256!!! TCHAR fname[MAX_SUPPORTED_PATH_LEN];
int save_count = 0; //TODO: once this crosses 9999 bad infinite-loop type things happen, look into that one day int save_count = 0; //TODO: once this crosses 9999 bad infinite-loop type things happen, look into that one day
FRESULT result; FRESULT result;
FILINFO fnoba; FILINFO fnoba;
@ -1796,7 +1798,7 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
//check out the userfriendly ini file for config-information //check out the userfriendly ini file for config-information
int readConfigFile(void) int readConfigFile(void)
{ {
TCHAR filename[32]; TCHAR filename[MAX_SUPPORTED_PATH_LEN];
sprintf(filename, "/"ED64_FIRMWARE_PATH"/ALT64.INI"); sprintf(filename, "/"ED64_FIRMWARE_PATH"/ALT64.INI");
FRESULT result; FRESULT result;
@ -1911,7 +1913,7 @@ void readSDcard(display_context_t disp, char *directory)
// for (int i = 0; i < dir->size; i++) // for (int i = 0; i < dir->size; i++)
// { // {
// frec = dir->rec[i]; // frec = dir->rec[i];
// u8 rom_cfg_file[128]; // u8 rom_cfg_file[MAX_SUPPORTED_PATH_LEN];
// //set rom_cfg // //set rom_cfg
// sprintf(rom_cfg_file, "/"ED64_FIRMWARE_PATH"/CFG/%s", frec->name); // sprintf(rom_cfg_file, "/"ED64_FIRMWARE_PATH"/CFG/%s", frec->name);
@ -2241,7 +2243,7 @@ void bootRom(display_context_t disp, int silent)
{ {
if (boot_save != 0) if (boot_save != 0)
{ {
TCHAR cfg_file[32]; TCHAR cfg_file[MAX_SUPPORTED_PATH_LEN];
//set cfg file with last loaded cart info and save-type //set cfg file with last loaded cart info and save-type
sprintf(cfg_file, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path); sprintf(cfg_file, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path);
@ -2434,7 +2436,7 @@ void drawShortInfoBox(display_context_t disp, char *text, u8 mode)
void readRomConfig(display_context_t disp, char *short_filename, char *full_filename) void readRomConfig(display_context_t disp, char *short_filename, char *full_filename)
{ {
TCHAR cfg_filename[256]; TCHAR cfg_filename[MAX_SUPPORTED_PATH_LEN];
sprintf(rom_filename, "%s", short_filename); sprintf(rom_filename, "%s", short_filename);
rom_filename[strlen(rom_filename) - 4] = '\0'; // cut extension rom_filename[strlen(rom_filename) - 4] = '\0'; // cut extension
sprintf(cfg_filename, "/"ED64_FIRMWARE_PATH"/CFG/%s.CFG", rom_filename); sprintf(cfg_filename, "/"ED64_FIRMWARE_PATH"/CFG/%s.CFG", rom_filename);
@ -2672,7 +2674,7 @@ void drawToplistBox(display_context_t disp, int line)
// if (res != FR_OK) break; // if (res != FR_OK) break;
// path[i] = 0; // path[i] = 0;
} else { /* It is a file. */ } else { /* It is a file. */
TCHAR rom_cfg_file[128]; TCHAR rom_cfg_file[MAX_SUPPORTED_PATH_LEN];
//set rom_cfg //set rom_cfg
sprintf(rom_cfg_file, path, fno.fname); sprintf(rom_cfg_file, path, fno.fname);
@ -4197,7 +4199,7 @@ void handleInput(display_context_t disp, sprite_t *contr)
else else
sprintf(name_file, "%s/%s", pwd, list[cursor].filename); sprintf(name_file, "%s/%s", pwd, list[cursor].filename);
TCHAR rom_cfg_file[128]; TCHAR rom_cfg_file[MAX_SUPPORTED_PATH_LEN];
u8 resp = 0; u8 resp = 0;