mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-25 20:16:53 +01:00
automatically create preview image dirs if they don't exist
This commit is contained in:
parent
f4d6743273
commit
50413d4e53
@ -698,6 +698,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
|
||||
|
@ -34,6 +34,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);
|
||||
|
@ -633,7 +633,6 @@ DefaultSettings ()
|
||||
GCSettings.SaveMethod = DEVICE_AUTO; // Auto, SD, USB, Network (SMB)
|
||||
sprintf (GCSettings.LoadFolder, "%s/roms", APPFOLDER); // Path to game files
|
||||
sprintf (GCSettings.SaveFolder, "%s/saves", APPFOLDER); // Path to save files
|
||||
//sprintf (GCSettings.CheatFolder, "%s/cheats", APPFOLDER); // Path to cheat files
|
||||
sprintf (GCSettings.ScreenshotsFolder, "%s/screenshots", APPFOLDER);
|
||||
sprintf (GCSettings.BorderFolder, "%s/borders", APPFOLDER);
|
||||
sprintf (GCSettings.CoverFolder, "%s/covers", APPFOLDER); // Path to cover files
|
||||
@ -839,6 +838,17 @@ bool LoadPrefs()
|
||||
if(prefFound)
|
||||
FixInvalidSettings();
|
||||
|
||||
// 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