mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-20 10:19:15 +01:00
*Fixed settings crash on too long paths
*Added new directory creation function. Now you set unlimited subfolders for covers/discimages. The programm creates the subfolders automaticly on download now.
This commit is contained in:
parent
e311e8790c
commit
988f8b250a
24
source/cfg.c
24
source/cfg.c
@ -156,6 +156,30 @@ bool cfg_map(char *name, char *val, short *var, short id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int subfoldercheck(char * dircovers) {
|
||||||
|
//check forsubfolders
|
||||||
|
char dircheck[100];
|
||||||
|
char dirslash[100];
|
||||||
|
int cnt = 0;
|
||||||
|
char * pch;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
sprintf(dirslash, "%s/", dircovers);
|
||||||
|
|
||||||
|
if(stat(dirslash, &st) != 0) {
|
||||||
|
pch = strrchr(dircovers, '/');
|
||||||
|
cnt = pch-dircovers;
|
||||||
|
snprintf(dircheck, cnt+1, "%s", dircovers);
|
||||||
|
subfoldercheck(dircheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mkdir(dircovers, 0777) == -1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool cfg_bool(char *name, short *var)
|
bool cfg_bool(char *name, short *var)
|
||||||
{
|
{
|
||||||
return (cfg_map(name, "0", var, 0) || cfg_map(name, "1", var, 1));
|
return (cfg_map(name, "0", var, 0) || cfg_map(name, "1", var, 1));
|
||||||
|
@ -156,6 +156,7 @@ void CFG_Load(int argc, char **argv);
|
|||||||
struct Game_CFG* CFG_get_game_opt(u8 *id);
|
struct Game_CFG* CFG_get_game_opt(u8 *id);
|
||||||
bool CFG_save_game_opt(u8 *id);
|
bool CFG_save_game_opt(u8 *id);
|
||||||
bool CFG_forget_game_opt(u8 *id);
|
bool CFG_forget_game_opt(u8 *id);
|
||||||
|
int subfoldercheck(char * directory);
|
||||||
|
|
||||||
//Astidof - Begin of modification
|
//Astidof - Begin of modification
|
||||||
enum {
|
enum {
|
||||||
|
@ -1596,18 +1596,22 @@ ProgressDownloadWindow(int choice2)
|
|||||||
char dircovers[100];
|
char dircovers[100];
|
||||||
snprintf(dircovers,strlen(CFG.covers_path),"%s",CFG.covers_path);
|
snprintf(dircovers,strlen(CFG.covers_path),"%s",CFG.covers_path);
|
||||||
if (mkdir(dircovers, 0777) == -1) {
|
if (mkdir(dircovers, 0777) == -1) {
|
||||||
|
if(subfoldercheck(dircovers) != 1) {
|
||||||
WindowPrompt("Error:","Can't create directory","OK",0,0,0);
|
WindowPrompt("Error:","Can't create directory","OK",0,0,0);
|
||||||
cntMissFiles = 0;
|
cntMissFiles = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(stat(CFG.disc_path,&st) != 0) {
|
if(stat(CFG.disc_path,&st) != 0) {
|
||||||
char dirdiscs[100];
|
char dirdiscs[100];
|
||||||
snprintf(dirdiscs,strlen(CFG.disc_path),"%s",CFG.disc_path);
|
snprintf(dirdiscs,strlen(CFG.disc_path),"%s",CFG.disc_path);
|
||||||
if (mkdir(dirdiscs, 0777) == -1) {
|
if (mkdir(dirdiscs, 0777) == -1) {
|
||||||
|
if(subfoldercheck(dirdiscs) != 1) {
|
||||||
WindowPrompt("Error:","Can't create directory","OK",0,0,0);
|
WindowPrompt("Error:","Can't create directory","OK",0,0,0);
|
||||||
cntMissFiles = 0;
|
cntMissFiles = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (i < cntMissFiles) {
|
while (i < cntMissFiles) {
|
||||||
|
|
||||||
@ -1855,7 +1859,7 @@ err:
|
|||||||
* Opens an on-screen keyboard window, with the data entered being stored
|
* Opens an on-screen keyboard window, with the data entered being stored
|
||||||
* into the specified variable.
|
* into the specified variable.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
static int OnScreenKeyboard(char * var, u16 maxlen)
|
static int OnScreenKeyboard(char * var, u32 maxlen)
|
||||||
{
|
{
|
||||||
int save = -1;
|
int save = -1;
|
||||||
|
|
||||||
@ -3242,6 +3246,7 @@ static int MenuSettings()
|
|||||||
{
|
{
|
||||||
int menu = MENU_NONE;
|
int menu = MENU_NONE;
|
||||||
int ret;
|
int ret;
|
||||||
|
char cfgtext[20];
|
||||||
|
|
||||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol);
|
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol);
|
||||||
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, vol);
|
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, vol);
|
||||||
@ -3579,11 +3584,33 @@ static int MenuSettings()
|
|||||||
else if(CFG.parentalcontrol == 2) sprintf(options2.value[5], "2");
|
else if(CFG.parentalcontrol == 2) sprintf(options2.value[5], "2");
|
||||||
else if(CFG.parentalcontrol == 3) sprintf(options2.value[5], "3");
|
else if(CFG.parentalcontrol == 3) sprintf(options2.value[5], "3");
|
||||||
|
|
||||||
sprintf(options2.value[6], CFG.covers_path);
|
|
||||||
|
|
||||||
sprintf(options2.value[7], CFG.disc_path);
|
if (strlen(CFG.covers_path) < (9 + 3)) {
|
||||||
|
sprintf(cfgtext, "%s", CFG.covers_path);
|
||||||
|
} else {
|
||||||
|
strncpy(cfgtext, CFG.covers_path, 9);
|
||||||
|
cfgtext[9] = '\0';
|
||||||
|
strncat(cfgtext, "...", 3);
|
||||||
|
}
|
||||||
|
sprintf(options2.value[6], "%s", cfgtext);
|
||||||
|
|
||||||
sprintf(options2.value[8], CFG.theme_path);
|
if (strlen(CFG.disc_path) < (9 + 3)) {
|
||||||
|
sprintf(cfgtext, "%s", CFG.disc_path);
|
||||||
|
} else {
|
||||||
|
strncpy(cfgtext, CFG.disc_path, 9);
|
||||||
|
cfgtext[9] = '\0';
|
||||||
|
strncat(cfgtext, "...", 3);
|
||||||
|
}
|
||||||
|
sprintf(options2.value[7], "%s", cfgtext);
|
||||||
|
|
||||||
|
if (strlen(CFG.theme_path) < (9 + 3)) {
|
||||||
|
sprintf(cfgtext, "%s", CFG.theme_path);
|
||||||
|
} else {
|
||||||
|
strncpy(cfgtext, CFG.theme_path, 9);
|
||||||
|
cfgtext[9] = '\0';
|
||||||
|
strncat(cfgtext, "...", 3);
|
||||||
|
}
|
||||||
|
sprintf(options2.value[8], "%s", cfgtext);
|
||||||
|
|
||||||
ret = optionBrowser2.GetClickedOption();
|
ret = optionBrowser2.GetClickedOption();
|
||||||
|
|
||||||
@ -3643,9 +3670,9 @@ static int MenuSettings()
|
|||||||
mainWindow->Remove(&page2Btn);
|
mainWindow->Remove(&page2Btn);
|
||||||
w.Remove(&backBtn);
|
w.Remove(&backBtn);
|
||||||
w.Remove(&lockBtn);
|
w.Remove(&lockBtn);
|
||||||
char entered[50] = "";
|
char entered[43] = "";
|
||||||
strncpy(entered, CFG.covers_path, sizeof(entered));
|
strncpy(entered, CFG.covers_path, sizeof(entered));
|
||||||
int result = OnScreenKeyboard(entered, 50);
|
int result = OnScreenKeyboard(entered,43);
|
||||||
mainWindow->Append(&optionBrowser2);
|
mainWindow->Append(&optionBrowser2);
|
||||||
mainWindow->Append(&page1Btn);
|
mainWindow->Append(&page1Btn);
|
||||||
mainWindow->Append(&page2Btn);
|
mainWindow->Append(&page2Btn);
|
||||||
@ -3671,9 +3698,9 @@ static int MenuSettings()
|
|||||||
mainWindow->Remove(&page2Btn);
|
mainWindow->Remove(&page2Btn);
|
||||||
w.Remove(&backBtn);
|
w.Remove(&backBtn);
|
||||||
w.Remove(&lockBtn);
|
w.Remove(&lockBtn);
|
||||||
char entered[50] = "";
|
char entered[43] = "";
|
||||||
strncpy(entered, CFG.disc_path, sizeof(entered));
|
strncpy(entered, CFG.disc_path, sizeof(entered));
|
||||||
int result = OnScreenKeyboard(entered, 50);
|
int result = OnScreenKeyboard(entered, 43);
|
||||||
mainWindow->Append(&optionBrowser2);
|
mainWindow->Append(&optionBrowser2);
|
||||||
mainWindow->Append(&page1Btn);
|
mainWindow->Append(&page1Btn);
|
||||||
mainWindow->Append(&page2Btn);
|
mainWindow->Append(&page2Btn);
|
||||||
@ -3699,9 +3726,9 @@ static int MenuSettings()
|
|||||||
mainWindow->Remove(&page2Btn);
|
mainWindow->Remove(&page2Btn);
|
||||||
w.Remove(&backBtn);
|
w.Remove(&backBtn);
|
||||||
w.Remove(&lockBtn);
|
w.Remove(&lockBtn);
|
||||||
char entered[50] = "";
|
char entered[43] = "";
|
||||||
strncpy(entered, CFG.theme_path, sizeof(entered));
|
strncpy(entered, CFG.theme_path, sizeof(entered));
|
||||||
int result = OnScreenKeyboard(entered, 50);
|
int result = OnScreenKeyboard(entered, 43);
|
||||||
mainWindow->Append(&optionBrowser2);
|
mainWindow->Append(&optionBrowser2);
|
||||||
mainWindow->Append(&page1Btn);
|
mainWindow->Append(&page1Btn);
|
||||||
mainWindow->Append(&page2Btn);
|
mainWindow->Append(&page2Btn);
|
||||||
|
Loading…
Reference in New Issue
Block a user