diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-08-02 02:21:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-08-15 10:06:21 +0900 |
| commit | 242c8a93d9a754df07c750f63259e3e23d5fc5d4 (patch) | |
| tree | 2524e714c3ff9fae131c9913a4d8f3b3d311c77e /sys.c | |
| parent | 3d64c9165ba8ae6a06ece0817ae246b21f6f661a (diff) | |
| download | ducc-242c8a93d9a754df07c750f63259e3e23d5fc5d4.tar.gz ducc-242c8a93d9a754df07c750f63259e3e23d5fc5d4.tar.zst ducc-242c8a93d9a754df07c750f63259e3e23d5fc5d4.zip | |
feat: do not use hard-coded ducc include path
Diffstat (limited to 'sys.c')
| -rw-r--r-- | sys.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -0,0 +1,15 @@ +char* get_self_path() { + char* buf = calloc(PATH_MAX, sizeof(char)); + ssize_t len = readlink("/proc/self/exe", buf, PATH_MAX - 1); + if (len == -1 || len == PATH_MAX - 1) { + return NULL; + } + buf[len] = '\0'; + return buf; +} + +// It returns a path not including final / except for root directory. +char* get_self_dir() { + char* path = get_self_path(); + return dirname(path); +} |
