about summary refs log tree commit diff
path: root/readfile.c
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2025-03-24 21:01:37 +0300
committerNakidai <nakidai@disroot.org>2025-03-24 21:01:37 +0300
commitf312b357ab2ec3cf83a67945f3641b964a59e8d2 (patch)
tree425f3371eee770f64e268e9964dba29ad17bd410 /readfile.c
parentad9d6a199db7c28f8b20f131dfb55a26e0e251de (diff)
download3cl-f312b357ab2ec3cf83a67945f3641b964a59e8d2.tar.gz
3cl-f312b357ab2ec3cf83a67945f3641b964a59e8d2.zip
Add code
Diffstat (limited to 'readfile.c')
-rw-r--r--readfile.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/readfile.c b/readfile.c
new file mode 100644
index 0000000..d4d17f8
--- /dev/null
+++ b/readfile.c
@@ -0,0 +1,19 @@
+#include "cccl.h"
+
+#include <stdlib.h>
+
+#include <sys/stat.h>
+
+
+int cccl_allocfile(const char *path, struct cccl_File *file)
+{
+    struct stat st;
+    int err = stat(path, &st);
+    if (err)
+        return err;
+
+    file->size = st.st_size;
+    file->buffer = malloc(file->size);
+
+    return !file->buffer;
+}