aboutsummaryrefslogtreecommitdiff
path: root/contrib/extractor/System.cpp
diff options
context:
space:
mode:
authorXTZGZoReX <none@none>2009-03-18 20:10:37 +0100
committerXTZGZoReX <none@none>2009-03-18 20:10:37 +0100
commit5f2e9f1ed190b3108a55efe809463c0b1ed401bd (patch)
tree7d18a6d4ec478ccb9d4cda3213863d9cc1b8771a /contrib/extractor/System.cpp
parent14f475d2ce468833915cd9215439f6016cbf118b (diff)
* Fixed extractor on systems with 2GB fopen() limit. Author: arrai
--HG-- branch : trunk
Diffstat (limited to 'contrib/extractor/System.cpp')
-rw-r--r--contrib/extractor/System.cpp22
1 files changed, 20 insertions, 2 deletions
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 <fcntl.h>
+
+#if defined( __GNUC__ )
+ #define _open open
+ #define _close close
+ #ifndef O_BINARY
+ #define O_BINARY 0
+ #endif
+#else
+ #include <io.h>
+#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;
}