77 wxString resourcesDir;
81 if (wxGetEnv(
"EMBER_RESOURCES", &envPath)) {
82 if (wxFileName::DirExists(envPath)) {
83 wxLogMessage(
"ResourcePath: Using EMBER_RESOURCES environment variable");
84 resourcesDir = envPath;
85 if (!resourcesDir.EndsWith(wxFileName::GetPathSeparator())) {
86 resourcesDir += wxFileName::GetPathSeparator();
90 wxLogWarning(
"ResourcePath: EMBER_RESOURCES path does not exist: %s", envPath);
95 wxString exePath = wxStandardPaths::Get().GetExecutablePath();
96 wxFileName exeFileName(exePath);
97 wxString exeDir = exeFileName.GetPath();
100 wxArrayString candidates;
103 candidates.Add(exeDir + wxFileName::GetPathSeparator() +
"resources" + wxFileName::GetPathSeparator());
106 wxFileName parentDir(exeDir);
107 parentDir.RemoveLastDir();
108 candidates.Add(parentDir.GetPath() + wxFileName::GetPathSeparator() +
"resources" + wxFileName::GetPathSeparator());
111 wxFileName grandparentDir(parentDir.GetPath());
112 grandparentDir.RemoveLastDir();
113 candidates.Add(grandparentDir.GetPath() + wxFileName::GetPathSeparator() +
"resources" +
114 wxFileName::GetPathSeparator());
117 for (
const wxString &candidate : candidates) {
119 wxString testPath = candidate +
"icons";
120 if (wxFileName::DirExists(testPath)) {
125 testPath = candidate +
"config";
126 if (wxFileName::DirExists(testPath)) {
131 testPath = candidate +
"buttons";
132 if (wxFileName::DirExists(testPath)) {
138 wxString cwdResources = wxGetCwd() + wxFileName::GetPathSeparator() +
"resources" + wxFileName::GetPathSeparator();
139 if (wxFileName::DirExists(cwdResources +
"icons") || wxFileName::DirExists(cwdResources +
"config") ||
140 wxFileName::DirExists(cwdResources +
"buttons")) {
141 wxLogWarning(
"ResourcePath: Falling back to CWD-relative resources (not recommended)");
146 return wxEmptyString;