diff --git a/src/common/platform/posix/cocoa/i_system.mm b/src/common/platform/posix/cocoa/i_system.mm index 971e7aad70..4251a8282d 100644 --- a/src/common/platform/posix/cocoa/i_system.mm +++ b/src/common/platform/posix/cocoa/i_system.mm @@ -173,12 +173,14 @@ unsigned int I_MakeRNGSeed() FString I_GetCWD() { - char curdir[PATH_MAX]; - if (!getcwd(curdir, countof(curdir))) + char* curdir = get_current_dir_name(); + if (!curdir) { return ""; } - return curdir; + FString ret(curdir); + free(curdir); + return ret; } bool I_ChDir(const char* path) diff --git a/src/common/platform/posix/sdl/i_system.cpp b/src/common/platform/posix/sdl/i_system.cpp index 2f3e3e75ec..14630b5ce5 100644 --- a/src/common/platform/posix/sdl/i_system.cpp +++ b/src/common/platform/posix/sdl/i_system.cpp @@ -412,12 +412,14 @@ FString I_GetFromClipboard (bool use_primary_selection) FString I_GetCWD() { - char curdir[PATH_MAX]; - if (!getcwd(curdir, countof(curdir))) + char* curdir = get_current_dir_name(); + if (!curdir) { return ""; } - return curdir; + FString ret(curdir); + free(curdir); + return ret; } bool I_ChDir(const char* path)