-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: absolute resource path is loaded at runtime and not absolute pat…
…h of the directory from that the executable is called
- Loading branch information
Showing
18 changed files
with
66 additions
and
47 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 was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,7 +1,34 @@ | ||
#include "Utility.hpp" | ||
|
||
std::string getResourcePath() { | ||
std::filesystem::path relativeResourcePath = "resources/"; | ||
std::filesystem::path absoluteResourcePath = std::filesystem::absolute(relativeResourcePath); | ||
return absoluteResourcePath.string(); | ||
} | ||
#ifdef _WIN32 | ||
#include <windows.h> | ||
|
||
std::string getResourcesDirPath() { | ||
char path[MAX_PATH]; | ||
HMODULE hModule = GetModuleHandle(NULL); | ||
GetModuleFileName(hModule, path, MAX_PATH); | ||
return std::filesystem::path(path).remove_filename().string() + "resources/"; | ||
} | ||
|
||
#elif __linux__ | ||
#include <unistd.h> | ||
|
||
std::string getResourcesDirPath() { | ||
char result[PATH_MAX]; | ||
ssize_t count = readlink("/proc/self/exe", result, PATH_MAX); | ||
return std::filesystem::path(std::string(result, (count > 0) ? count : 0)).remove_filename().string() + "resources/"; | ||
} | ||
|
||
#elif __APPLE__ | ||
#include <mach-o/dyld.h> | ||
|
||
std::string getResourcesDirPath() { | ||
char path[PATH_MAX]; | ||
uint32_t size = sizeof(path); | ||
_NSGetExecutablePath(path, &size); | ||
return std::filesystem::path(path).remove_filename().string() + "resources/"; | ||
} | ||
|
||
#else | ||
#error "Unsupported platform" | ||
#endif |
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
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
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