From 00d8692ebe1b6d25620934257c9cddc2b0bcc796 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Tue, 16 Jun 2009 08:28:50 +0000 Subject: [PATCH] *Moved gct.cpp and gct.h to branches since its not used and seems somehow to cause troubles (it shouldnt be but somehow it does -_-) *Changed subfoldercreation function --- gui.pnproj | 2 +- source/listfiles.c | 28 ++++++++++++++++++++++++++-- source/listfiles.h | 2 +- source/main.cpp | 2 +- source/prompts/PromptWindows.cpp | 32 ++++++++++---------------------- source/settings/cfg.c | 24 ------------------------ source/settings/cfg.h | 1 - 7 files changed, 39 insertions(+), 52 deletions(-) diff --git a/gui.pnproj b/gui.pnproj index a12549eb..f62d3f22 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/listfiles.c b/source/listfiles.c index f36fd833..7ea09001 100644 --- a/source/listfiles.c +++ b/source/listfiles.c @@ -35,6 +35,30 @@ while ((file = readdir(dir))) return false; } +bool subfoldercreate(char * fullpath) { + //check forsubfolders + char dircheck[300]; + char dirnoslash[300]; + char * pch = NULL; + u32 cnt = 0; + struct stat st; + + snprintf(dirnoslash, strlen(fullpath), "%s", fullpath); + + if(stat(fullpath, &st) != 0) { + pch = strrchr(dirnoslash, '/'); + cnt = pch-dirnoslash; + snprintf(dircheck, cnt+2, "%s", dirnoslash); + subfoldercreate(dircheck); + }; + + if (mkdir(dirnoslash, 0777) == -1) { + return false; + } + +return true; +} + char * GetFileName(int i) { return alldirfiles[i]; @@ -49,11 +73,11 @@ s32 filenamescmp(const void *a, const void *b) int GetAllDirFiles(char * filespath) { int countfiles = 0; - + struct stat st; DIR_ITER* dir; dir = diropen (filespath); - + if (dir == NULL) //If empty return 0; while (dirnext(dir,filenames,&st) == 0) diff --git a/source/listfiles.h b/source/listfiles.h index 7281c05b..e0c99546 100644 --- a/source/listfiles.h +++ b/source/listfiles.h @@ -9,7 +9,7 @@ extern "C" bool findfile(const char * filename, const char * path); char * GetFileName(int i); int GetAllDirFiles(char * filespath); - +bool subfoldercreate(char * fullpath); #ifdef __cplusplus } diff --git a/source/main.cpp b/source/main.cpp index ca564329..1bb8dfcb 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -122,7 +122,7 @@ main(int argc, char *argv[]) WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); fontSystem = new FreeTypeGX(); - char *fontPath=0; + char *fontPath = NULL; asprintf(&fontPath, "%sfont.ttf", CFG.theme_path); fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0); fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index 274d94e6..28b6ed17 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -1988,23 +1988,15 @@ ProgressDownloadWindow(int choice2) //check if directory exist and if not create one struct stat st; if(stat(Settings.covers_path, &st) != 0) { - char dircovers[100]; - snprintf(dircovers,strlen(Settings.covers_path),"%s",Settings.covers_path); - if (mkdir(dircovers, 0777) == -1) { - if(subfoldercheck(dircovers) != 1) { - WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0); - cntMissFiles = 0; - } + if(subfoldercreate(Settings.covers_path) != 1) { + WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0); + cntMissFiles = 0; } } if(stat(Settings.disc_path,&st) != 0) { - char dirdiscs[100]; - snprintf(dirdiscs,strlen(Settings.disc_path),"%s",Settings.disc_path); - if (mkdir(dirdiscs, 0777) == -1) { - if(subfoldercheck(dirdiscs) != 1) { - WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0); - cntMissFiles = 0; - } + if(subfoldercreate(Settings.disc_path) != 1) { + WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0); + cntMissFiles = 0; } } @@ -2221,14 +2213,10 @@ int ProgressUpdateWindow() struct stat st; if(stat(Settings.update_path, &st) != 0) { - char dir[100]; - snprintf(dir,strlen(Settings.update_path),"%s",Settings.update_path); - if (mkdir(dir, 0777) == -1) { - if(subfoldercheck(dir) != 1) { - WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0); - ret = -1; - failed = -1; - } + if(subfoldercreate(Settings.update_path) != 1) { + WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0); + ret = -1; + failed = -1; } } diff --git a/source/settings/cfg.c b/source/settings/cfg.c index e20dd3d8..8c20f8ab 100644 --- a/source/settings/cfg.c +++ b/source/settings/cfg.c @@ -171,30 +171,6 @@ bool cfg_map(char *name, char *val, short *var, short id) 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) { return (cfg_map(name, "0", var, 0) || cfg_map(name, "1", var, 1)); diff --git a/source/settings/cfg.h b/source/settings/cfg.h index de75bc44..39cf3558 100644 --- a/source/settings/cfg.h +++ b/source/settings/cfg.h @@ -195,7 +195,6 @@ struct Game_NUM* CFG_get_game_num(u8 *id); bool CFG_save_game_opt(u8 *id); bool CFG_save_game_num(u8 *id); bool CFG_forget_game_opt(u8 *id); -int subfoldercheck(char * directory); //Astidof - Begin of modification enum {