commit 185f9811078e2b08702e121eee4671b4a8732d89
parent 64903e2e887e33cf2f2d0683c4a51fa91d5c45e2
Author: keyle <keyle@capsule.org>
Date: Sat, 9 May 2026 18:02:37 +1000
minor
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/utils.c b/src/utils.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
char* read_file(const char* filename) {
FILE* fp = fopen(filename, "r");
@@ -19,3 +20,17 @@ char* read_file(const char* filename) {
source[fsize] = 0;
return source;
}
+
+void separate_file_from_path(const char* fullpath, char** out_path, char** out_filename) {
+ char* path = strdup(fullpath);
+ char* filename = strrchr(path, '/');
+ if (filename == NULL) {
+ printf("No path found\n");
+ exit(1);
+ }
+ *filename = '\0';
+ filename++;
+ *out_path = strdup(path);
+ *out_filename = strdup(filename);
+ free(path);
+}
diff --git a/src/utils.h b/src/utils.h
@@ -1,3 +1,5 @@
#pragma once
char* read_file(const char* filename);
+
+void separate_file_from_path(const char* fullpath, char** out_path, char** out_filename);