Skip to content

Commit

Permalink
- use char* get_current_dir_name() in Mac/Linux to save the cwd in th…
Browse files Browse the repository at this point in the history
…e shell open function
  • Loading branch information
madame-rachelle committed Aug 17, 2022
1 parent a2369b9 commit e261132
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
22 changes: 12 additions & 10 deletions src/common/platform/posix/cocoa/i_system.mm
Expand Up @@ -186,18 +186,20 @@ bool I_ChDir(const char* path)
return chdir(path) == 0;
}

void I_OpenShellFolder(const char* folder)
void I_OpenShellFolder(const char* infolder)
{
char curdir[PATH_MAX];
if (!getcwd (curdir, countof(curdir)))
char* curdir = get_current_dir_name();

if (!chdir(infolder))
{
Printf ("Current path too long\n");
return;
Printf("Opening folder: %s\n", infolder);
system("open .");
chdir(curdir);
}

chdir(folder);
Printf("Opening folder: %s\n", folder);
std::system("open .");
chdir(curdir);
else
{
Printf("Unable to open directory '%s\n", infolder);
}
free(curdir);
}

22 changes: 12 additions & 10 deletions src/common/platform/posix/sdl/i_system.cpp
Expand Up @@ -447,18 +447,20 @@ unsigned int I_MakeRNGSeed()
return seed;
}

void I_OpenShellFolder(const char* folder)
void I_OpenShellFolder(const char* infolder)
{
char curdir[PATH_MAX];
if (!getcwd (curdir, countof(curdir)))
char* curdir = get_current_dir_name();

if (!chdir(infolder))
{
Printf ("Current path too long\n");
return;
Printf("Opening folder: %s\n", infolder);
system("xdg-open .");
chdir(curdir);
}

chdir(folder);
Printf("Opening folder: %s\n", folder);
std::system("xdg-open .");
chdir(curdir);
else
{
Printf("Unable to open directory '%s\n", infolder);
}
free(curdir);
}

0 comments on commit e261132

Please sign in to comment.