mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 08:25:18 +01:00
automatically create preview image dirs if they don't exist
This commit is contained in:
parent
b66d66e82e
commit
6788d15aae
@ -699,6 +699,20 @@ ParseDirectory(bool waitParse, bool filter)
|
||||
return browser.numEntries;
|
||||
}
|
||||
|
||||
bool CreateDirectory(char * path)
|
||||
{
|
||||
DIR *dir = opendir(path);
|
||||
if (!dir) {
|
||||
if(mkdir(path, 0777) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
closedir(dir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* AllocSaveBuffer ()
|
||||
* Clear and allocate the savebuffer
|
||||
|
@ -37,6 +37,7 @@ void CreateAppPath(char * origpath);
|
||||
bool GetFileSize(int i);
|
||||
void FindAndSelectLastLoadedFile();
|
||||
int ParseDirectory(bool waitParse = false, bool filter = true);
|
||||
bool CreateDirectory(char * path);
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
size_t LoadFile(char * rbuffer, char *filepath, size_t length, bool silent);
|
||||
|
@ -651,8 +651,9 @@ bool LoadPrefs()
|
||||
|
||||
prefLoaded = true; // attempted to load preferences
|
||||
|
||||
if(prefFound)
|
||||
if(prefFound) {
|
||||
FixInvalidSettings();
|
||||
}
|
||||
|
||||
// rename snes9x to snes9xgx
|
||||
if(GCSettings.LoadMethod == DEVICE_SD)
|
||||
@ -690,6 +691,17 @@ bool LoadPrefs()
|
||||
if(strcmp(GCSettings.ArtworkFolder, "snes9x/artworks") == 0)
|
||||
sprintf(GCSettings.ArtworkFolder, "snes9xgx/artworks");
|
||||
|
||||
// attempt to create directories if they don't exist
|
||||
if(GCSettings.LoadMethod != DEVICE_AUTO) {
|
||||
char dirPath[MAXPATHLEN];
|
||||
sprintf(dirPath, "%s%s", pathPrefix[GCSettings.LoadMethod], GCSettings.ScreenshotsFolder);
|
||||
CreateDirectory(dirPath);
|
||||
sprintf(dirPath, "%s%s", pathPrefix[GCSettings.LoadMethod], GCSettings.CoverFolder);
|
||||
CreateDirectory(dirPath);
|
||||
sprintf(dirPath, "%s%s", pathPrefix[GCSettings.LoadMethod], GCSettings.ArtworkFolder);
|
||||
CreateDirectory(dirPath);
|
||||
}
|
||||
|
||||
ResetText();
|
||||
return prefFound;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user