aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/stdio.c20
-rw-r--r--std/stdio.sloth3
2 files changed, 21 insertions, 2 deletions
diff --git a/std/stdio.c b/std/stdio.c
index f6dbeaf..b5f1dd0 100644
--- a/std/stdio.c
+++ b/std/stdio.c
@@ -26,3 +26,23 @@ void curshide() {
void cursshow() {
print("\x1b[?25h");
}
+
+char* filer(char* path) {
+ FILE *fptr = fopen(path, "rb");
+ char *contents = 0;
+
+ if(fptr == NULL) {
+ return "File not found";
+ }
+ fseek(fptr, 0, SEEK_END);
+ long size = ftell(fptr);
+ fseek(fptr, 0, SEEK_SET);
+
+ contents = malloc(size);
+ fread(contents, 1, size, fptr);
+ fclose(fptr);
+
+ return contents;
+}
+
+
diff --git a/std/stdio.sloth b/std/stdio.sloth
index 77c9af0..37a2d07 100644
--- a/std/stdio.sloth
+++ b/std/stdio.sloth
@@ -1,6 +1,6 @@
foreign fn print(str: String) Void;
foreign fn readln() String;
-
+foreign fn filer(path: String) String;
foreign fn curshide();
foreign fn cursshow();
@@ -9,4 +9,3 @@ fn println(str: String) Void {
print("\n");
}
-