- Added _O_BINARY to open() calls on Win32.
authorarno <arno@e16421f0-f15b-0410-abcd-98678b794739>
Thu, 19 Nov 2009 07:42:01 +0000 (07:42 +0000)
committerarno <arno@e16421f0-f15b-0410-abcd-98678b794739>
Thu, 19 Nov 2009 07:42:01 +0000 (07:42 +0000)
- Fixed build bug on Linux.

git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@589 e16421f0-f15b-0410-abcd-98678b794739

hashtree.cpp
tests/SConscript

index 01c07c5..b278a2f 100644 (file)
 #include <fcntl.h>
 #include "compat.h"
 
+#ifdef _WIN32
+#define OPENFLAGS              O_RDWR|O_CREAT|_O_BINARY
+#else
+#define OPENFLAGS              O_RDWR|O_CREAT
+#endif
+
 
 using namespace p2tp;
 
@@ -77,7 +83,7 @@ root_hash_(root_hash), fd_(0), hash_fd_(0), data_recheck_(true),
 peak_count_(0), hashes_(NULL), size_(0), sizek_(0),
 complete_(0), completek_(0)
 {
-       fd_ = open(filename,O_RDWR|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+       fd_ = open(filename,OPENFLAGS,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
        if (fd_<0)
         return;
     char hfn[1024] = "";
@@ -86,7 +92,7 @@ complete_(0), completek_(0)
         strcat(hfn, ".mhash");
     } else
         strcpy(hfn,hash_filename);
-    hash_fd_ = open(hfn,O_RDWR|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+    hash_fd_ = open(hfn,OPENFLAGS,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
     if (hash_fd_<0)
         return;
     if (root_hash_==Sha1Hash::ZERO) { // fresh submit, hash it
index cd50a95..09ea949 100644 (file)
@@ -6,7 +6,7 @@ Import("libs")
 Import("libpath")
 
 cpppath = env["CPPPATH"]
-if DEBUG:
+if DEBUG and sys.platform == "win32":
        libs = ['p2tp','gtestd'] + libs  # order is important, crypto needs to be last
 else:
        libs = ['p2tp','gtest'] + libs  # order is important, crypto needs to be last