75 wxString resourcesDir;
79 if (wxGetEnv(
"EMBER_RESOURCES", &envPath)) {
80 if (wxFileName::DirExists(envPath)) {
81 wxLogDebug(
"ResourcePath: Using EMBER_RESOURCES environment variable");
82 resourcesDir = envPath;
83 if (!resourcesDir.EndsWith(wxFileName::GetPathSeparator())) {
84 resourcesDir += wxFileName::GetPathSeparator();
88 wxLogWarning(
"ResourcePath: EMBER_RESOURCES path does not exist: %s", envPath);
93 wxString exePath = wxStandardPaths::Get().GetExecutablePath();
94 wxFileName exeFileName(exePath);
95 wxString exeDir = exeFileName.GetPath();
98 wxArrayString candidates;
101 candidates.Add(exeDir + wxFileName::GetPathSeparator() +
"resources" + wxFileName::GetPathSeparator());
104 wxFileName parentDir(exeDir);
105 parentDir.RemoveLastDir();
106 candidates.Add(parentDir.GetPath() + wxFileName::GetPathSeparator() +
"resources" + wxFileName::GetPathSeparator());
109 wxFileName grandparentDir(parentDir.GetPath());
110 grandparentDir.RemoveLastDir();
111 candidates.Add(grandparentDir.GetPath() + wxFileName::GetPathSeparator() +
"resources" +
112 wxFileName::GetPathSeparator());
115 for (
const wxString &candidate : candidates) {
117 wxString testPath = candidate +
"icons";
118 if (wxFileName::DirExists(testPath)) {
123 testPath = candidate +
"config";
124 if (wxFileName::DirExists(testPath)) {
129 testPath = candidate +
"buttons";
130 if (wxFileName::DirExists(testPath)) {
136 wxString cwdResources = wxGetCwd() + wxFileName::GetPathSeparator() +
"resources" + wxFileName::GetPathSeparator();
137 if (wxFileName::DirExists(cwdResources +
"icons") || wxFileName::DirExists(cwdResources +
"config") ||
138 wxFileName::DirExists(cwdResources +
"buttons")) {
139 wxLogWarning(
"ResourcePath: Falling back to CWD-relative resources (not recommended)");
144 return wxEmptyString;