X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=fs.c;h=17319de834de41888d5099e21b3ef9b4fa57b26e;hp=c91805e52af160eeff680a7cad82302ab8816c41;hb=6fee3ec363e6d6cb53e2bf452ecbf48ad1c4bd6a;hpb=033cf7c7d397c3fdc23a1448b0068000219efef6 diff --git a/fs.c b/fs.c index c91805e..17319de 100644 --- a/fs.c +++ b/fs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 + * Copyright (C) 2012, 2013, 2014 * Dale Weiler * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -20,6 +20,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#define GMQCC_PLATFORM_HEADER #include "gmqcc.h" #include "platform.h" @@ -59,7 +60,8 @@ int fs_file_error(fs_file_t *fp) { } int fs_file_getc(fs_file_t *fp) { - return platform_fgetc((FILE*)fp); + int get = platform_fgetc((FILE*)fp); + return (get == EOF) ? FS_FILE_EOF : get; } int fs_file_puts(fs_file_t *fp, const char *str) { @@ -67,6 +69,11 @@ int fs_file_puts(fs_file_t *fp, const char *str) { } int fs_file_seek(fs_file_t *fp, long int off, int whence) { + switch(whence) { + case FS_FILE_SEEK_CUR: whence = SEEK_CUR; break; + case FS_FILE_SEEK_SET: whence = SEEK_SET; break; + case FS_FILE_SEEK_END: whence = SEEK_END; break; + } return platform_fseek((FILE*)fp, off, whence); }