From 498c691eb0dd19b23f70421484aa6d738f35e73c Mon Sep 17 00:00:00 2001 From: Jan Sucan Date: Thu, 11 Apr 2019 18:44:34 +0200 Subject: Initial commit --- file.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 file.c (limited to 'file.c') diff --git a/file.c b/file.c new file mode 100644 index 0000000..6b70f5e --- /dev/null +++ b/file.c @@ -0,0 +1,32 @@ +#include +#include + +#include "file.h" +#include "print.h" + +long +file_size(FILE * const file) +{ + fpos_t p; + + if ((fgetpos(file, &p) != 0) + || (fseek(file, 0L, SEEK_END) != 0)) { + return -1; + } + + const long size = ftell(file); + + if (fsetpos(file, &p) != 0) { + return -1; + } + + return size; +} + +FILE * +file_open(const char * const path, const char * const mode) +{ + /* TODO: odstranit tuto funkciu? */ + FILE * f = fopen(path, mode); + return f; +} -- cgit v1.2.3