From 5f2e9f1ed190b3108a55efe809463c0b1ed401bd Mon Sep 17 00:00:00 2001 From: XTZGZoReX Date: Wed, 18 Mar 2009 20:10:37 +0100 Subject: * Fixed extractor on systems with 2GB fopen() limit. Author: arrai --HG-- branch : trunk --- contrib/extractor/System.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'contrib/extractor/System.cpp') diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp index 75cc5ba92e4..afa2301e487 100644 --- a/contrib/extractor/System.cpp +++ b/contrib/extractor/System.cpp @@ -16,6 +16,23 @@ #include "loadlib/adt.h" #include "loadlib/wdt.h" +#include + +#if defined( __GNUC__ ) + #define _open open + #define _close close + #ifndef O_BINARY + #define O_BINARY 0 + #endif +#else + #include +#endif + +#ifdef O_LARGEFILE + #define OPEN_FLAGS (O_RDONLY | O_BINARY | O_LARGEFILE) +#else + #define OPEN_FLAGS (O_RDONLY | O_BINARY) +#endif extern ArchiveSet gOpenArchives; @@ -81,9 +98,10 @@ void CreateDir( const std::string& Path ) bool FileExists( const char* FileName ) { - if(FILE* fp = fopen( FileName, "rb" )) + int fp = _open(FileName, OPEN_FLAGS); + if(fp != -1) { - fclose(fp); + _close(fp); return true; } -- cgit v1.2.3