From b09b9ac1b19da4d06dec10bebd7f6176ce225855 Mon Sep 17 00:00:00 2001 From: molivier Date: Thu, 18 Nov 2004 14:08:27 +0000 Subject: [PATCH] Quick hack to fix the calls to "open" on Win32 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4772 d7cf8633-e32d-0410-b094-e92efae38249 --- fs.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fs.c b/fs.c index 4e5ff558..258e8a77 100644 --- a/fs.c +++ b/fs.c @@ -46,6 +46,13 @@ // use syscalls instead of f* functions #define FS_USESYSCALLS +// Win32 requires us to add O_BINARY, but the other OSes don't have it +#ifdef FS_USESYSCALLS +# ifndef O_BINARY +# define O_BINARY 0 +# endif +#endif + /* @@ -560,7 +567,7 @@ pack_t *FS_LoadPackPK3 (const char *packfile) int real_nb_files; #ifdef FS_USESYSCALLS - packhandle = open (packfile, O_RDONLY); + packhandle = open (packfile, O_RDONLY | O_BINARY); if (packhandle < 0) return NULL; #else @@ -770,7 +777,7 @@ pack_t *FS_LoadPackPAK (const char *packfile) dpackfile_t *info; // temporary alloc, allowing huge pack directories #ifdef FS_USESYSCALLS - packhandle = open (packfile, O_RDONLY); + packhandle = open (packfile, O_RDONLY | O_BINARY); if (packhandle < 0) return NULL; read (packhandle, (void *)&header, sizeof(header)); @@ -1042,11 +1049,11 @@ static qfile_t* FS_SysOpen (const char* filepath, const char* mode) #ifdef FS_USESYSCALLS if (strchr(mode, 'r')) - file->stream = open (filepath, O_RDONLY); + file->stream = open (filepath, O_RDONLY | O_BINARY); else if (strchr(mode, 'w')) - file->stream = open (filepath, O_WRONLY | O_CREAT | O_TRUNC, 0666); + file->stream = open (filepath, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0666); else if (strchr(mode, 'a')) - file->stream = open (filepath, O_RDWR | O_CREAT | O_APPEND, 0666); + file->stream = open (filepath, O_RDWR | O_BINARY | O_CREAT | O_APPEND, 0666); else file->stream = -1; if (file->stream < 0) -- 2.39.2