From 03c725c0daf8c311a95c6df2eb6101ee6620443c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Aug 2022 23:27:49 +0200 Subject: [PATCH] - use NSFileManager on macOS to handle the current directory. --- src/common/platform/posix/cocoa/i_system.mm | 22 +++++++-------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/common/platform/posix/cocoa/i_system.mm b/src/common/platform/posix/cocoa/i_system.mm index 58617cd8125..fa0134d6f21 100644 --- a/src/common/platform/posix/cocoa/i_system.mm +++ b/src/common/platform/posix/cocoa/i_system.mm @@ -173,31 +173,23 @@ unsigned int I_MakeRNGSeed() FString I_GetCWD() { - char curdir[PATH_MAX]; - if (!getcwd(curdir, countof(curdir))) - { - return ""; - } - return curdir; + NSString *currentpath = [[NSFileManager defaultManager] currentDirectoryPath]; + return currentpath.UTF8String; } bool I_ChDir(const char* path) { - return chdir(path) == 0; + return [[NSFileManager defaultManager] changeCurrentDirectoryPath:[NSString stringWithUTF8String:path]]; } void I_OpenShellFolder(const char* folder) { - char curdir[PATH_MAX]; - if (!getcwd (curdir, countof(curdir))) - { - Printf ("Current path too long\n"); - return; - } + NSFileManager *filemgr = [NSFileManager defaultManager]; + NSString *currentpath = [filemgr currentDirectoryPath]; - chdir(folder); + [filemgr changeCurrentDirectoryPath:[NSString stringWithUTF8String:folder]]; Printf("Opening folder: %s\n", folder); std::system("open ."); - chdir(curdir); + [filemgr changeCurrentDirectoryPath:currentpath]; }