aboutsummaryrefslogtreecommitdiffhomepage
path: root/sys.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-02 02:21:48 +0900
committernsfisis <nsfisis@gmail.com>2025-08-15 10:06:21 +0900
commit242c8a93d9a754df07c750f63259e3e23d5fc5d4 (patch)
tree2524e714c3ff9fae131c9913a4d8f3b3d311c77e /sys.c
parent3d64c9165ba8ae6a06ece0817ae246b21f6f661a (diff)
downloadducc-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.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sys.c b/sys.c
new file mode 100644
index 0000000..aa7b13d
--- /dev/null
+++ b/sys.c
@@ -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);
+}