- use char* get_current_dir_name() in Mac/Linux to save the cwd in the shell open function

This commit is contained in:
Rachael Alexanderson 2022-08-17 16:32:09 -04:00
parent a2369b945c
commit e261132db0
2 changed files with 26 additions and 22 deletions

View file

@ -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)))
{
Printf ("Current path too long\n");
return;
}
char* curdir = get_current_dir_name();
chdir(folder);
Printf("Opening folder: %s\n", folder);
std::system("open .");
chdir(curdir);
if (!chdir(infolder))
{
Printf("Opening folder: %s\n", infolder);
system("open .");
chdir(curdir);
}
else
{
Printf("Unable to open directory '%s\n", infolder);
}
free(curdir);
}

View file

@ -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)))
{
Printf ("Current path too long\n");
return;
}
char* curdir = get_current_dir_name();
chdir(folder);
Printf("Opening folder: %s\n", folder);
std::system("xdg-open .");
chdir(curdir);
if (!chdir(infolder))
{
Printf("Opening folder: %s\n", infolder);
system("xdg-open .");
chdir(curdir);
}
else
{
Printf("Unable to open directory '%s\n", infolder);
}
free(curdir);
}