From: arno Date: Thu, 19 Nov 2009 07:42:01 +0000 (+0000) Subject: - Added _O_BINARY to open() calls on Win32. X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=1001c7e7a55f1fa782c92965ea8f2a72e402fc6b;p=swift-upb.git - Added _O_BINARY to open() calls on Win32. - Fixed build bug on Linux. git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@589 e16421f0-f15b-0410-abcd-98678b794739 --- diff --git a/hashtree.cpp b/hashtree.cpp index 01c07c5..b278a2f 100644 --- a/hashtree.cpp +++ b/hashtree.cpp @@ -15,6 +15,12 @@ #include #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 diff --git a/tests/SConscript b/tests/SConscript index cd50a95..09ea949 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -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