-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
#ifndef _WIN32 | ||
|
||
#include "Utils/AppRuntime.h" | ||
|
||
#include <dlfcn.h> | ||
|
||
#include "Utils/Platform.h" | ||
|
||
MAA_NS_BEGIN | ||
|
||
void init_app_dir(); | ||
|
||
static std::filesystem::path s_app_dir_cache; | ||
|
||
const std::filesystem::path& app_dir() | ||
{ | ||
if (s_app_dir_cache.empty()) { | ||
init_app_dir(); | ||
} | ||
|
||
return s_app_dir_cache; | ||
} | ||
|
||
void init_app_dir() | ||
{ | ||
Dl_info dl_info{}; | ||
if (dladdr((void*)init_app_dir, &dl_info) == 0) { | ||
return; | ||
} | ||
|
||
s_app_dir_cache = MAA_NS::path(dl_info.dli_fname).parent_path(); | ||
} | ||
|
||
MAA_NS_END | ||
|
||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#ifdef _WIN32 | ||
|
||
#include "Utils/AppRuntime.h" | ||
|
||
#include "Utils/Platform.h" | ||
|