PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
sreadfile.c
Go to the documentation of this file.
1#include <sys/io.h>
2
3char* sreadfile(const char* path)
4{
5 fd_t fd = open(path);
6 if (fd == ERR)
7 {
8 return NULL;
9 }
10 char* str = sread(fd);
11 close(fd);
12 return str;
13}
fd_t open(const char *path)
System call for opening files.
Definition open.c:9
uint64_t close(fd_t fd)
System call for closing files.
Definition close.c:9
char * sread(fd_t fd)
Wrapper for reading a file directly into a null-terminated string.
Definition sread.c:5
char * sreadfile(const char *path)
Wrapper for reading an entire file directly into a null-terminated string.
Definition sreadfile.c:3
#define NULL
Pointer error value.
Definition NULL.h:23
#define ERR
Integer error value.
Definition ERR.h:17
__UINT64_TYPE__ fd_t
A file descriptor.
Definition fd_t.h:12