mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 08:55:45 +00:00
BACKENDS: Add better error handling to OSystem_Win32::getDefaultConfigFileName()
This commit is contained in:
parent
dd21952f98
commit
7fa3a8bbff
@ -155,18 +155,31 @@ Common::String OSystem_Win32::getDefaultConfigFileName() {
|
||||
error("Unable to access user profile directory");
|
||||
|
||||
strcat(configFile, "\\Application Data");
|
||||
CreateDirectory(configFile, NULL);
|
||||
|
||||
// If the directory already exists (as it should in most cases),
|
||||
// we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND)
|
||||
if (!CreateDirectory(configFile, NULL)) {
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
error("Cannot create Application data folder");
|
||||
}
|
||||
}
|
||||
|
||||
strcat(configFile, "\\ScummVM");
|
||||
CreateDirectory(configFile, NULL);
|
||||
if (!CreateDirectory(configFile, NULL)) {
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
error("Cannot create ScummVM application data folder");
|
||||
}
|
||||
|
||||
strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
|
||||
|
||||
FILE *tmp = NULL;
|
||||
if ((tmp = fopen(configFile, "r")) == NULL) {
|
||||
// Check windows directory
|
||||
char oldConfigFile[MAXPATHLEN];
|
||||
GetWindowsDirectory(oldConfigFile, MAXPATHLEN);
|
||||
uint ret = GetWindowsDirectory(oldConfigFile, MAXPATHLEN);
|
||||
if (ret == 0 || ret > MAXPATHLEN)
|
||||
error("Cannot retrieve the path of the Windows directory");
|
||||
|
||||
strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE);
|
||||
if ((tmp = fopen(oldConfigFile, "r"))) {
|
||||
strcpy(configFile, oldConfigFile);
|
||||
@ -178,7 +191,10 @@ Common::String OSystem_Win32::getDefaultConfigFileName() {
|
||||
}
|
||||
} else {
|
||||
// Check windows directory
|
||||
GetWindowsDirectory(configFile, MAXPATHLEN);
|
||||
uint ret = GetWindowsDirectory(configFile, MAXPATHLEN);
|
||||
if (ret == 0 || ret > MAXPATHLEN)
|
||||
error("Cannot retrieve the path of the Windows directory");
|
||||
|
||||
strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user