mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Fix get_app_path() impl for Linux and Mac OS X
This commit is contained in:
parent
866c770d89
commit
83ba85ff09
@ -9,6 +9,15 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#if __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#include "base/path.h"
|
||||
|
||||
#define MAXPATHLEN 1024
|
||||
|
||||
namespace base {
|
||||
|
||||
@ -44,7 +53,22 @@ void remove_directory(const string& path)
|
||||
|
||||
string get_app_path()
|
||||
{
|
||||
return getexecname();
|
||||
std::vector<char> path(MAXPATHLEN);
|
||||
|
||||
#if __APPLE__
|
||||
|
||||
uint32_t size = path.size();
|
||||
while (_NSGetExecutablePath(&path[0], &size) == -1)
|
||||
path.resize(size);
|
||||
|
||||
#else
|
||||
|
||||
if (readlink("/proc/self/exe", &path[0], path.size()) > 0)
|
||||
return std::string(&path[0]);
|
||||
|
||||
#endif
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
string get_temp_path()
|
||||
|
Loading…
x
Reference in New Issue
Block a user