mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add platform::get_executable_path (#638)
This commit is contained in:
parent
ecd95967c4
commit
b14bad5d24
5 changed files with 88 additions and 8 deletions
24
src/util/platform_internal.cpp
Normal file
24
src/util/platform_internal.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <filesystem>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
namespace platform::internal {
|
||||
std::filesystem::path get_executable_path() {
|
||||
#ifdef __APPLE__
|
||||
char buffer[1024];
|
||||
uint32_t size = sizeof(buffer);
|
||||
if (_NSGetExecutablePath(buffer, &size) == 0) {
|
||||
return std::filesystem::canonical(std::filesystem::path(buffer));
|
||||
} else {
|
||||
return std::filesystem::path();
|
||||
}
|
||||
#endif
|
||||
return std::filesystem::path();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue