aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cc1/sys.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-03 17:29:12 +0900
committernsfisis <nsfisis@gmail.com>2026-05-03 18:42:58 +0900
commit3654ce578e6fff53950874adf7e0e4ae0a6eb956 (patch)
tree5b6c04273de38dba70b7c25e55da144f5f7c37da /src/cc1/sys.c
parent1b406b13b03055d2b2d08e8279a4a80c41ca7c20 (diff)
downloadducc-3654ce578e6fff53950874adf7e0e4ae0a6eb956.tar.gz
ducc-3654ce578e6fff53950874adf7e0e4ae0a6eb956.tar.zst
ducc-3654ce578e6fff53950874adf7e0e4ae0a6eb956.zip
refactor: organize directory structureHEADmain
Diffstat (limited to 'src/cc1/sys.c')
-rw-r--r--src/cc1/sys.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cc1/sys.c b/src/cc1/sys.c
new file mode 100644
index 0000000..693062a
--- /dev/null
+++ b/src/cc1/sys.c
@@ -0,0 +1,21 @@
+#include "sys.h"
+#include <libgen.h>
+#include <linux/limits.h>
+#include <unistd.h>
+#include "../lib/ducc.h"
+
+static 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);
+}