From 60ba65fbfda0c21a69fc3d62e50dedf8e0335a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Sat, 7 Oct 2023 19:34:06 -0300 Subject: [PATCH] fix GetChars in linux/macOS --- src/common/platform/posix/cocoa/i_main.mm | 2 +- .../platform/posix/osx/i_specialpaths.mm | 12 +++++----- .../platform/posix/osx/iwadpicker_cocoa.mm | 10 ++++---- src/common/utility/cmdlib.cpp | 2 +- src/gameconfigfile.cpp | 24 +++++++++---------- src/posix/i_steam.cpp | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/common/platform/posix/cocoa/i_main.mm b/src/common/platform/posix/cocoa/i_main.mm index 50353ba3de0..10f3a60ab63 100644 --- a/src/common/platform/posix/cocoa/i_main.mm +++ b/src/common/platform/posix/cocoa/i_main.mm @@ -348,7 +348,7 @@ - (BOOL)application:(NSApplication*)theApplication openFile:(NSString*)filename for (size_t i = 0, count = s_argv.Size(); i < count; ++i) { - if (0 == strcmp(s_argv[i], charFileName)) + if (0 == strcmp(s_argv[i].GetChars(), charFileName)) { return FALSE; } diff --git a/src/common/platform/posix/osx/i_specialpaths.mm b/src/common/platform/posix/osx/i_specialpaths.mm index d51bd4ca5a4..7d55157efd2 100644 --- a/src/common/platform/posix/osx/i_specialpaths.mm +++ b/src/common/platform/posix/osx/i_specialpaths.mm @@ -105,7 +105,7 @@ FString M_GetAppDataPath(bool create) } path += "/" GAMENAMELOWERCASE; - if (create) CreatePath(path); + if (create) CreatePath(path.GetChars()); return path; } @@ -127,7 +127,7 @@ FString M_GetCachePath(bool create) } path += "/zdoom/cache"; - if (create) CreatePath(path); + if (create) CreatePath(path.GetChars()); return path; } @@ -169,9 +169,9 @@ FString M_GetConfigPath(bool for_reading) { // There seems to be no way to get Preferences path via NSFileManager path += "/Preferences/"; - CreatePath(path); + CreatePath(path.GetChars()); - if (!DirExists(path)) + if (!DirExists(path.GetChars())) { path = FString(); } @@ -200,7 +200,7 @@ FString M_GetScreenshotsPath() { path += "/" GAME_DIR "/Screenshots/"; } - CreatePath(path); + CreatePath(path.GetChars()); return path; } @@ -241,7 +241,7 @@ FString M_GetDocumentsPath() path += "/" GAME_DIR "/"; } - CreatePath(path); + CreatePath(path.GetChars()); return path; } diff --git a/src/common/platform/posix/osx/iwadpicker_cocoa.mm b/src/common/platform/posix/osx/iwadpicker_cocoa.mm index e72aa5aad5c..f680829bfee 100644 --- a/src/common/platform/posix/osx/iwadpicker_cocoa.mm +++ b/src/common/platform/posix/osx/iwadpicker_cocoa.mm @@ -86,13 +86,13 @@ - (IWADTableData *)init:(WadStuff *) wads num:(int) numwads for(int i = 0;i < numwads;i++) { NSMutableDictionary *record = [[NSMutableDictionary alloc] initWithCapacity:NUM_COLUMNS]; - const char* filename = strrchr(wads[i].Path, '/'); + const char* filename = strrchr(wads[i].Path.GetChars(), '/'); if(filename == NULL) - filename = wads[i].Path; + filename = wads[i].Path.GetChars(); else filename++; [record setObject:[NSString stringWithUTF8String:filename] forKey:[NSString stringWithUTF8String:tableHeaders[COLUMN_IWAD]]]; - [record setObject:[NSString stringWithUTF8String:wads[i].Name] forKey:[NSString stringWithUTF8String:tableHeaders[COLUMN_GAME]]]; + [record setObject:[NSString stringWithUTF8String:wads[i].Name.GetChars()] forKey:[NSString stringWithUTF8String:tableHeaders[COLUMN_GAME]]]; [data addObject:record]; [record release]; } @@ -397,9 +397,9 @@ static void RestartWithParameters(const WadStuff& wad, NSString* parameters) [arguments addObject:GetArchitectureString()]; [arguments addObject:executablePath]; [arguments addObject:@"-iwad"]; - [arguments addObject:[NSString stringWithUTF8String:wad.Path]]; + [arguments addObject:[NSString stringWithUTF8String:wad.Path.GetChars()]]; [arguments addObject:@"+defaultiwad"]; - [arguments addObject:[NSString stringWithUTF8String:wad.Name]]; + [arguments addObject:[NSString stringWithUTF8String:wad.Name.GetChars()]]; [arguments addObject:cvarArgument]; for (int i = 1, count = Args->NumArgs(); i < count; ++i) diff --git a/src/common/utility/cmdlib.cpp b/src/common/utility/cmdlib.cpp index 88a37f362a2..b8c14045338 100644 --- a/src/common/utility/cmdlib.cpp +++ b/src/common/utility/cmdlib.cpp @@ -905,7 +905,7 @@ FString NicePath(const char *path) slash = path + strlen(path); } FString who(path, slash - path); - pwstruct = getpwnam(who); + pwstruct = getpwnam(who.GetChars()); } if (pwstruct == NULL) { diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 3e4f96c0071..a0f27899e70 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -108,10 +108,10 @@ FGameConfigFile::FGameConfigFile () SetValueForKey ("Path", ".", true); SetValueForKey ("Path", "$DOOMWADDIR", true); #ifdef __APPLE__ - SetValueForKey ("Path", user_docs, true); - SetValueForKey ("Path", user_app_support, true); + SetValueForKey ("Path", user_docs.GetChars(), true); + SetValueForKey ("Path", user_app_support.GetChars(), true); SetValueForKey ("Path", "$PROGDIR", true); - SetValueForKey ("Path", local_app_support, true); + SetValueForKey ("Path", local_app_support.GetChars(), true); #elif !defined(__unix__) SetValueForKey ("Path", "$HOME", true); SetValueForKey ("Path", "$PROGDIR", true); @@ -133,10 +133,10 @@ FGameConfigFile::FGameConfigFile () { SetSection ("FileSearch.Directories", true); #ifdef __APPLE__ - SetValueForKey ("Path", user_docs, true); - SetValueForKey ("Path", user_app_support, true); + SetValueForKey ("Path", user_docs.GetChars(), true); + SetValueForKey ("Path", user_app_support.GetChars(), true); SetValueForKey ("Path", "$PROGDIR", true); - SetValueForKey ("Path", local_app_support, true); + SetValueForKey ("Path", local_app_support.GetChars(), true); #elif !defined(__unix__) SetValueForKey ("Path", "$PROGDIR", true); #else @@ -156,14 +156,14 @@ FGameConfigFile::FGameConfigFile () { SetSection("SoundfontSearch.Directories", true); #ifdef __APPLE__ - SetValueForKey("Path", user_docs + "/soundfonts", true); - SetValueForKey("Path", user_docs + "/fm_banks", true); - SetValueForKey("Path", user_app_support + "/soundfonts", true); - SetValueForKey("Path", user_app_support + "/fm_banks", true); + SetValueForKey("Path", (user_docs + "/soundfonts").GetChars(), true); + SetValueForKey("Path", (user_docs + "/fm_banks").GetChars(), true); + SetValueForKey("Path", (user_app_support + "/soundfonts").GetChars(), true); + SetValueForKey("Path", (user_app_support + "/fm_banks").GetChars(), true); SetValueForKey("Path", "$PROGDIR/soundfonts", true); SetValueForKey("Path", "$PROGDIR/fm_banks", true); - SetValueForKey("Path", local_app_support + "/soundfonts", true); - SetValueForKey("Path", local_app_support + "/fm_banks", true); + SetValueForKey("Path", (local_app_support + "/soundfonts").GetChars(), true); + SetValueForKey("Path", (local_app_support + "/fm_banks").GetChars(), true); #elif !defined(__unix__) SetValueForKey("Path", "$PROGDIR/soundfonts", true); SetValueForKey("Path", "$PROGDIR/fm_banks", true); diff --git a/src/posix/i_steam.cpp b/src/posix/i_steam.cpp index 82c2c9d9826..913ae398912 100644 --- a/src/posix/i_steam.cpp +++ b/src/posix/i_steam.cpp @@ -202,7 +202,7 @@ TArray I_GetSteamPath() try { - SteamInstallFolders = ParseSteamRegistry(regPath); + SteamInstallFolders = ParseSteamRegistry(regPath.GetChars()); } catch(class CRecoverableError &error) { @@ -221,7 +221,7 @@ TArray I_GetSteamPath() { struct stat st; FString candidate(SteamInstallFolders[i] + "/" + AppInfo[app].BasePath); - if(DirExists(candidate)) + if(DirExists(candidate.GetChars())) result.Push(candidate); } }