- change the way posix folders are opened - fixes issue #1707

This commit is contained in:
Rachael Alexanderson 2022-08-14 18:37:53 -04:00
parent 03d76027cf
commit a9cadd345d
2 changed files with 47 additions and 12 deletions

View File

@ -173,15 +173,33 @@ unsigned int I_MakeRNGSeed()
void I_OpenShellFolder(const char* folder) void I_OpenShellFolder(const char* folder)
{ {
std::string x = (std::string)"open \"" + (std::string)folder + "\""; char curdir[256];
if (!getcwd (curdir, countof(curdir)))
{
Printf ("Current path too long\n");
return;
}
chdir(folder);
Printf("Opening folder: %s\n", folder); Printf("Opening folder: %s\n", folder);
std::system(x.c_str()); std::system("open .");
chdir(curdir);
} }
void I_OpenShellFile(const char* file) void I_OpenShellFile(const char* file)
{ {
std::string x = (std::string)"open \"" + (std::string)file + "\""; char curdir[256];
x.erase(x.find_last_of('/'), std::string::npos); if (!getcwd (curdir, countof(curdir)))
Printf("Opening folder to file: %s\n", file); {
std::system(x.c_str()); Printf ("Current path too long\n");
return;
}
std::string folder = file;
folder.erase(folder.find_last_of('/'), std::string::npos);
chdir(folder.c_str());
Printf("Opening folder: %s\n", folder.c_str());
std::system("open .");
chdir(curdir);
} }

View File

@ -434,16 +434,33 @@ unsigned int I_MakeRNGSeed()
void I_OpenShellFolder(const char* folder) void I_OpenShellFolder(const char* folder)
{ {
std::string x = (std::string)"xdg-open \"" + (std::string)folder + "\""; char curdir[256];
if (!getcwd (curdir, countof(curdir)))
{
Printf ("Current path too long\n");
return;
}
chdir(folder);
Printf("Opening folder: %s\n", folder); Printf("Opening folder: %s\n", folder);
std::system(x.c_str()); std::system("xdg-open .");
chdir(curdir);
} }
void I_OpenShellFile(const char* file) void I_OpenShellFile(const char* file)
{ {
std::string x = (std::string)"xdg-open \"" + (std::string)file + "\""; char curdir[256];
x.erase(x.find_last_of('/'), std::string::npos); if (!getcwd (curdir, countof(curdir)))
Printf("Opening folder to file: %s\n", file); {
std::system(x.c_str()); Printf ("Current path too long\n");
return;
}
std::string folder = file;
folder.erase(folder.find_last_of('/'), std::string::npos);
chdir(folder.c_str());
Printf("Opening folder: %s\n", folder.c_str());
std::system("xdg-open .");
chdir(curdir);
} }