Skip to content

Commit

Permalink
Merge syscoin#14: Fixes to allow building with msvc.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
laanwj committed Jan 16, 2019
2 parents 524b7e3 + d6eab93 commit 2fc1148
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "leveldb/c.h"

#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include "leveldb/cache.h"
#include "leveldb/comparator.h"
#include "leveldb/db.h"
Expand Down
7 changes: 7 additions & 0 deletions port/port_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@
#define STORAGE_LEVELDB_PORT_PORT_WIN_H_

#ifdef _MSC_VER
#if !(_MSC_VER >= 1900)
#define snprintf _snprintf
#endif
#define close _close
#define fread_unlocked _fread_nolock
#ifdef _WIN64
#define ssize_t int64_t
#else
#define ssize_t int32_t
#endif
#endif

#include <string>
Expand Down
6 changes: 4 additions & 2 deletions util/env_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,16 @@ uint64_t Win32Env::NowMicros()
static Status CreateDirInner( const std::string& dirname )
{
Status sRet;
DWORD attr = ::GetFileAttributes(dirname.c_str());
std::wstring dirnameW;
ToWidePath(dirname, dirnameW);
DWORD attr = ::GetFileAttributesW(dirnameW.c_str());
if (attr == INVALID_FILE_ATTRIBUTES) { // doesn't exist:
std::size_t slash = dirname.find_last_of("\\");
if (slash != std::string::npos){
sRet = CreateDirInner(dirname.substr(0, slash));
if (!sRet.ok()) return sRet;
}
BOOL result = ::CreateDirectory(dirname.c_str(), NULL);
BOOL result = ::CreateDirectoryW(dirnameW.c_str(), NULL);
if (result == FALSE) {
sRet = Status::IOError(dirname, "Could not create directory.");
return sRet;
Expand Down

0 comments on commit 2fc1148

Please sign in to comment.