Skip to content

Commit

Permalink
- change the way posix folders are opened - fixes issue #1707
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Aug 14, 2022
1 parent 03d7602 commit a9cadd3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
30 changes: 24 additions & 6 deletions src/common/platform/posix/cocoa/i_system.mm
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,33 @@ unsigned int I_MakeRNGSeed()

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);
std::system(x.c_str());
std::system("open .");
chdir(curdir);
}

void I_OpenShellFile(const char* file)
{
std::string x = (std::string)"open \"" + (std::string)file + "\"";
x.erase(x.find_last_of('/'), std::string::npos);
Printf("Opening folder to file: %s\n", file);
std::system(x.c_str());
char curdir[256];
if (!getcwd (curdir, countof(curdir)))
{
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);
}

29 changes: 23 additions & 6 deletions src/common/platform/posix/sdl/i_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,33 @@ unsigned int I_MakeRNGSeed()

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);
std::system(x.c_str());
std::system("xdg-open .");
chdir(curdir);
}

void I_OpenShellFile(const char* file)
{
std::string x = (std::string)"xdg-open \"" + (std::string)file + "\"";
x.erase(x.find_last_of('/'), std::string::npos);
Printf("Opening folder to file: %s\n", file);
std::system(x.c_str());
char curdir[256];
if (!getcwd (curdir, countof(curdir)))
{
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);
}

0 comments on commit a9cadd3

Please sign in to comment.