This commit is contained in:
@@ -15,8 +15,6 @@ int main(int arc, char** args) {
|
||||
|
||||
bool everythingIsOK = true;
|
||||
|
||||
AssetManager::setExePath(args[0]);
|
||||
|
||||
// CHECK PIECES FILES
|
||||
|
||||
PiecesFiles pf;
|
||||
|
||||
@@ -1,18 +1,33 @@
|
||||
#include "AssetManager.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h> //GetModuleFileNameW
|
||||
#else
|
||||
#include <limits.h>
|
||||
#include <unistd.h> //readlink
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static fs::path EXE_DIRECTORY;
|
||||
|
||||
void AssetManager::setExePath(const std::string& arg0) {
|
||||
EXE_DIRECTORY = fs::path(arg0).parent_path();
|
||||
static fs::path getExeDirectory(){
|
||||
#ifdef _WIN32
|
||||
wchar_t path[MAX_PATH] = { 0 };
|
||||
GetModuleFileNameW(NULL, path, MAX_PATH);
|
||||
return path;
|
||||
#else
|
||||
char result[PATH_MAX];
|
||||
ssize_t count = readlink("/proc/self/exe", result, PATH_MAX);
|
||||
return std::string(result, (count > 0) ? count : 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
static fs::path getEnv(const std::string& var) {
|
||||
char* env = std::getenv(var.c_str());
|
||||
return env ? env :
|
||||
#ifdef JMINOS_IGNORE_WORKDIR
|
||||
EXE_DIRECTORY.parent_path();
|
||||
getExeDirectory().parent_path().parent_path();
|
||||
#else
|
||||
"";
|
||||
#endif
|
||||
|
||||
@@ -15,9 +15,4 @@ class AssetManager {
|
||||
* @brief Used to save things
|
||||
*/
|
||||
static std::filesystem::path getConfigPath(const std::string& resource);
|
||||
|
||||
/**
|
||||
* @brief Set the current path of the executable
|
||||
*/
|
||||
static void setExePath(const std::string& arg0);
|
||||
};
|
||||
Reference in New Issue
Block a user