-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for wxwidget related paths for macos. added pathutils unit, it pr…
…ovides correct paths to "data" and "images" dirs relatively to executable.
- Loading branch information
1 parent
eb1d74d
commit 1114ed8
Showing
4 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <string> | ||
#include <memory> | ||
|
||
#include <wx/stdpaths.h> | ||
#include <wx/filename.h> | ||
|
||
|
||
namespace | ||
{ | ||
static std::string executableDir{}; | ||
static std::string dataDir{}; | ||
static std::string imagesBaseDir{}; | ||
|
||
std::string GetParentDirIfExists(const std::string& dir, const std::string& fallBackDir) | ||
{ | ||
auto lastSeparator = dir.find_last_of(wxFileName::GetPathSeparator()); | ||
|
||
if (lastSeparator != std::string::npos) | ||
{ | ||
return dir.substr(0, lastSeparator); | ||
} | ||
|
||
return fallBackDir; | ||
} | ||
|
||
std::string GetExecutableDir() | ||
{ | ||
if (executableDir.empty()) | ||
{ | ||
auto executablePath = wxStandardPaths::Get().GetExecutablePath(); | ||
auto pathStr = executablePath.ToStdString(); | ||
|
||
executableDir = GetParentDirIfExists(pathStr, wxGetCwd().ToStdString()); | ||
} | ||
|
||
return executableDir; | ||
} | ||
}; | ||
|
||
std::string GetDataPath() | ||
{ | ||
if (dataDir.empty()) | ||
{ | ||
dataDir = GetParentDirIfExists(GetExecutableDir(), GetExecutableDir()) + wxFileName::GetPathSeparator(); | ||
} | ||
|
||
return dataDir; | ||
} | ||
|
||
std::string GetImagesBasePath() | ||
{ | ||
if (imagesBaseDir.empty()) | ||
{ | ||
imagesBaseDir = GetDataPath() + "images/"; | ||
} | ||
|
||
return imagesBaseDir; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <string> | ||
|
||
|
||
std::string GetDataPath(); | ||
std::string GetImagesBasePath(); |