Skip to content

Commit

Permalink
- use NSFileManager on macOS to handle the current directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 17, 2022
1 parent 532a493 commit 03c725c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/common/platform/posix/cocoa/i_system.mm
Expand Up @@ -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];
}

0 comments on commit 03c725c

Please sign in to comment.