X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=fs.c;h=1e06ecc03f66621638a865539fdf3a14716db8a3;hp=c91805e52af160eeff680a7cad82302ab8816c41;hb=d8c09c200a681ae12d078559dac526aa2c8cc951;hpb=033cf7c7d397c3fdc23a1448b0068000219efef6 diff --git a/fs.c b/fs.c index c91805e..1e06ecc 100644 --- a/fs.c +++ b/fs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 + * Copyright (C) 2012, 2013, 2014, 2015 * 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); }