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