Skip to content

Commit

Permalink
- get_current_dir_name apparently does not exist on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 17, 2022
1 parent 7f3c09c commit 532a493
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/common/platform/posix/cocoa/i_system.mm
Original file line number Diff line number Diff line change
Expand Up @@ -173,35 +173,31 @@ unsigned int I_MakeRNGSeed()

FString I_GetCWD()
{
char* curdir = get_current_dir_name();
if (!curdir)
char curdir[PATH_MAX];
if (!getcwd(curdir, countof(curdir)))
{
return "";
}
FString ret(curdir);
free(curdir);
return ret;
return curdir;
}

bool I_ChDir(const char* path)
{
return chdir(path) == 0;
}

void I_OpenShellFolder(const char* infolder)
void I_OpenShellFolder(const char* folder)
{
char* curdir = get_current_dir_name();

if (!chdir(infolder))
{
Printf("Opening folder: %s\n", infolder);
system("open .");
chdir(curdir);
}
else
char curdir[PATH_MAX];
if (!getcwd (curdir, countof(curdir)))
{
Printf("Unable to open directory '%s\n", infolder);
Printf ("Current path too long\n");
return;
}
free(curdir);

chdir(folder);
Printf("Opening folder: %s\n", folder);
std::system("open .");
chdir(curdir);
}

0 comments on commit 532a493

Please sign in to comment.