]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - fs.c
Happy new year!
[xonotic/gmqcc.git] / fs.c
diff --git a/fs.c b/fs.c
index c91805e52af160eeff680a7cad82302ab8816c41..17319de834de41888d5099e21b3ef9b4fa57b26e 100644 (file)
--- 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);
 }