-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework include and lib search paths, update readme
- Loading branch information
Showing
18 changed files
with
345 additions
and
212 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
#include <limits.h> | ||
#include <stdlib.h> | ||
#include <libgen.h> | ||
#include <stdbool.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
||
#if defined(WIN32) | ||
#include <windows.h> | ||
#elif defined(__APPLE__) | ||
#include <mach-o/dyld.h> | ||
#endif | ||
|
||
char *get_binary_path(void) { | ||
char *dest = calloc(1,PATH_MAX); | ||
uint32_t size; | ||
#if defined(__linux__) | ||
realpath("/proc/self/exe", dest); | ||
#elif defined(WIN32) | ||
GetModuleFileName(NULL, dest, PATH_MAX); | ||
#elif defined(__APPLE__) | ||
size = PATH_MAX; | ||
_NSGetExecutablePath(dest, &size); | ||
#elif defined(__FreeBSD__) | ||
realpath("/proc/curproc/file", dest); | ||
#endif | ||
size = strlen(dest); | ||
if(size > 0) { | ||
return dest; | ||
} else { | ||
free(dest); | ||
return NULL; | ||
} | ||
} | ||
|
||
#ifdef APPDIR_TEST | ||
int main(int argc, char **argv) { | ||
char* p = get_binary_path(); | ||
if(p != NULL) { | ||
printf("Path = %s\n", dirname(p)); | ||
free(p); | ||
} | ||
return 0; | ||
} | ||
#endif |
Oops, something went wrong.