Fixed initialization of search paths on macOS

IWAD directories previously set in user configuration file led to inconsistent file and soundfont search paths
This commit is contained in:
alexey.lysiuk 2018-03-04 11:06:11 +02:00
parent c9613b2fd1
commit d802abec5b

View file

@ -73,6 +73,38 @@ FGameConfigFile::FGameConfigFile ()
{ {
#ifdef __APPLE__ #ifdef __APPLE__
FString user_docs, user_app_support, local_app_support; FString user_docs, user_app_support, local_app_support;
{
char cpath[PATH_MAX];
FSRef folder;
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
{
user_docs << cpath << "/" GAME_DIR;
}
else
{
user_docs = "~/" GAME_DIR;
}
if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
{
user_app_support << cpath << "/" GAME_DIR;
}
else
{
user_app_support = "~/Library/Application Support/" GAME_DIR;
}
if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
{
local_app_support << cpath << "/" GAME_DIR;
}
else
{
local_app_support = "Library/Application Support/" GAME_DIR;
}
}
#endif #endif
FString pathname; FString pathname;
@ -95,32 +127,10 @@ FGameConfigFile::FGameConfigFile ()
SetValueForKey ("Path", ".", true); SetValueForKey ("Path", ".", true);
SetValueForKey ("Path", "$DOOMWADDIR", true); SetValueForKey ("Path", "$DOOMWADDIR", true);
#ifdef __APPLE__ #ifdef __APPLE__
char cpath[PATH_MAX]; SetValueForKey ("Path", user_docs, true);
FSRef folder; SetValueForKey ("Path", user_app_support, true);
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
{
user_docs << cpath << "/" GAME_DIR;
SetValueForKey("Path", user_docs, true);
}
else
{
SetValueForKey("Path", "~/" GAME_DIR, true);
}
if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
{
user_app_support << cpath << "/" GAME_DIR;
SetValueForKey("Path", user_app_support, true);
}
SetValueForKey ("Path", "$PROGDIR", true); SetValueForKey ("Path", "$PROGDIR", true);
if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) && SetValueForKey ("Path", local_app_support, true);
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
{
local_app_support << cpath << "/" GAME_DIR;
SetValueForKey("Path", local_app_support, true);
}
#elif !defined(__unix__) #elif !defined(__unix__)
SetValueForKey ("Path", "$HOME", true); SetValueForKey ("Path", "$HOME", true);
SetValueForKey ("Path", "$PROGDIR", true); SetValueForKey ("Path", "$PROGDIR", true);