diff options
| author | Jan Sucan <sucanjan@fit.cvut.cz> | 2019-04-11 18:44:34 +0200 |
|---|---|---|
| committer | Jan Sucan <sucanjan@fit.cvut.cz> | 2019-04-11 18:44:34 +0200 |
| commit | 498c691eb0dd19b23f70421484aa6d738f35e73c (patch) | |
| tree | 10f244796344981ee6e5ddc5f3912372d7c5990b /file.c | |
Initial commit
Diffstat (limited to 'file.c')
| -rw-r--r-- | file.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +#include <errno.h> +#include <string.h> + +#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; +} |
