Skip to content

Commit 2fc1148

Browse files
committed
Merge bitcoin#14: Fixes to allow building with msvc.
d6eab93 Fixes to allow building with msvc. (Aaron Clauson) Pull request description: This PR would be very handy to facilitate building bitcoin with msvc. The [relevant parts of the patch were submitted](google/leveldb#521) upstream to the main leveldb source but there looks to be a bigger Windows port going on there at the moment. Tree-SHA512: 0183c6fb189ee3446c2de1f02b514dcb77b2e1d6524e127be2e396575eb6106e1081143b4b5a2a91c9cc8424dfcfc0230c4b4c55db6a66dceb6f61fb89f90f5a
2 parents 524b7e3 + d6eab93 commit 2fc1148

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

db/c.cc

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include "leveldb/c.h"
66

77
#include <stdlib.h>
8+
#ifndef WIN32
89
#include <unistd.h>
10+
#endif
911
#include "leveldb/cache.h"
1012
#include "leveldb/comparator.h"
1113
#include "leveldb/db.h"

port/port_win.h

+7
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@
3232
#define STORAGE_LEVELDB_PORT_PORT_WIN_H_
3333

3434
#ifdef _MSC_VER
35+
#if !(_MSC_VER >= 1900)
3536
#define snprintf _snprintf
37+
#endif
3638
#define close _close
3739
#define fread_unlocked _fread_nolock
40+
#ifdef _WIN64
41+
#define ssize_t int64_t
42+
#else
43+
#define ssize_t int32_t
44+
#endif
3845
#endif
3946

4047
#include <string>

util/env_win.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,16 @@ uint64_t Win32Env::NowMicros()
764764
static Status CreateDirInner( const std::string& dirname )
765765
{
766766
Status sRet;
767-
DWORD attr = ::GetFileAttributes(dirname.c_str());
767+
std::wstring dirnameW;
768+
ToWidePath(dirname, dirnameW);
769+
DWORD attr = ::GetFileAttributesW(dirnameW.c_str());
768770
if (attr == INVALID_FILE_ATTRIBUTES) { // doesn't exist:
769771
std::size_t slash = dirname.find_last_of("\\");
770772
if (slash != std::string::npos){
771773
sRet = CreateDirInner(dirname.substr(0, slash));
772774
if (!sRet.ok()) return sRet;
773775
}
774-
BOOL result = ::CreateDirectory(dirname.c_str(), NULL);
776+
BOOL result = ::CreateDirectoryW(dirnameW.c_str(), NULL);
775777
if (result == FALSE) {
776778
sRet = Status::IOError(dirname, "Could not create directory.");
777779
return sRet;

0 commit comments

Comments
 (0)