diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-06-28 16:21:15 -0500 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-06-28 16:21:15 -0500 |
| commit | 73843fa284968b4efb0ae51858cb37d0189c4b83 (patch) | |
| tree | 278982b5b0b8fdb933d5d57f801145ab7cbf99aa /std/stdio.c | |
| parent | 7d14243f769ad911d7c057b891ed89a95d7c1bfd (diff) | |
| download | sloth-73843fa284968b4efb0ae51858cb37d0189c4b83.tar.gz | |
filer added to std
Diffstat (limited to 'std/stdio.c')
| -rw-r--r-- | std/stdio.c | 20 |
1 files changed, 20 insertions, 0 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; +} + + |
