*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
This commit is contained in:
dimok321 2009-06-16 08:28:50 +00:00
parent ca3ab2f042
commit 00d8692ebe
7 changed files with 39 additions and 52 deletions

File diff suppressed because one or more lines are too long

View File

@ -35,6 +35,30 @@ while ((file = readdir(dir)))
return false; 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) char * GetFileName(int i)
{ {
return alldirfiles[i]; return alldirfiles[i];

View File

@ -9,7 +9,7 @@ extern "C"
bool findfile(const char * filename, const char * path); bool findfile(const char * filename, const char * path);
char * GetFileName(int i); char * GetFileName(int i);
int GetAllDirFiles(char * filespath); int GetAllDirFiles(char * filespath);
bool subfoldercreate(char * fullpath);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -122,7 +122,7 @@ main(int argc, char *argv[])
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
fontSystem = new FreeTypeGX(); fontSystem = new FreeTypeGX();
char *fontPath=0; char *fontPath = NULL;
asprintf(&fontPath, "%sfont.ttf", CFG.theme_path); asprintf(&fontPath, "%sfont.ttf", CFG.theme_path);
fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0); fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0);
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);

View File

@ -1988,23 +1988,15 @@ ProgressDownloadWindow(int choice2)
//check if directory exist and if not create one //check if directory exist and if not create one
struct stat st; struct stat st;
if(stat(Settings.covers_path, &st) != 0) { if(stat(Settings.covers_path, &st) != 0) {
char dircovers[100]; if(subfoldercreate(Settings.covers_path) != 1) {
snprintf(dircovers,strlen(Settings.covers_path),"%s",Settings.covers_path); WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0);
if (mkdir(dircovers, 0777) == -1) { cntMissFiles = 0;
if(subfoldercheck(dircovers) != 1) {
WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0);
cntMissFiles = 0;
}
} }
} }
if(stat(Settings.disc_path,&st) != 0) { if(stat(Settings.disc_path,&st) != 0) {
char dirdiscs[100]; if(subfoldercreate(Settings.disc_path) != 1) {
snprintf(dirdiscs,strlen(Settings.disc_path),"%s",Settings.disc_path); WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0);
if (mkdir(dirdiscs, 0777) == -1) { cntMissFiles = 0;
if(subfoldercheck(dirdiscs) != 1) {
WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0);
cntMissFiles = 0;
}
} }
} }
@ -2221,14 +2213,10 @@ int ProgressUpdateWindow()
struct stat st; struct stat st;
if(stat(Settings.update_path, &st) != 0) { if(stat(Settings.update_path, &st) != 0) {
char dir[100]; if(subfoldercreate(Settings.update_path) != 1) {
snprintf(dir,strlen(Settings.update_path),"%s",Settings.update_path); WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0);
if (mkdir(dir, 0777) == -1) { ret = -1;
if(subfoldercheck(dir) != 1) { failed = -1;
WindowPrompt(LANGUAGE.Error,LANGUAGE.Cantcreatedirectory,LANGUAGE.ok,0,0,0);
ret = -1;
failed = -1;
}
} }
} }

View File

@ -171,30 +171,6 @@ 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));

View File

@ -195,7 +195,6 @@ struct Game_NUM* CFG_get_game_num(u8 *id);
bool CFG_save_game_opt(u8 *id); bool CFG_save_game_opt(u8 *id);
bool CFG_save_game_num(u8 *id); bool CFG_save_game_num(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 {