From 95ae85a8ef45d11e222acc8021bc35c55ae39fa6 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Tue, 9 Mar 2021 05:23:37 +0100 Subject: Import project --- FileSystem.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 FileSystem.c (limited to 'FileSystem.c') diff --git a/FileSystem.c b/FileSystem.c new file mode 100755 index 0000000..b691746 --- /dev/null +++ b/FileSystem.c @@ -0,0 +1,41 @@ +#include "FileSystem.h" + +FILE *FileOpen(const char *path) +{ + if (!path) + { + return NULL; + } + + return fopen(path, "rb"); +} + +bool FileClose(FILE *file) +{ + if (!file) + { + return false; + } + + return fclose(file) == 0; +} + +bool FileRead(FILE *file, void *dst, const size_t size) +{ + if (!file || !dst || size == 0) + { + return false; + } + + return fread(dst, 1, size, file) == size; +} + +bool FileSeek(FILE *file, const size_t offset) +{ + if (!file) + { + return false; + } + + return fseek(file, offset, SEEK_SET) == 0; +} -- cgit v1.2.3