From d6eab93138884ee6c466fad5dadf2a1bfeb7cffd Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Wed, 25 Oct 2017 00:25:48 +1100 Subject: [PATCH] Fixes to allow building with msvc. --- db/c.cc | 2 ++ port/port_win.h | 7 +++++++ util/env_win.cc | 6 ++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/db/c.cc b/db/c.cc index 08ff0ad90ac00d..b23e3dcc9d06a1 100644 --- a/db/c.cc +++ b/db/c.cc @@ -5,7 +5,9 @@ #include "leveldb/c.h" #include +#ifndef WIN32 #include +#endif #include "leveldb/cache.h" #include "leveldb/comparator.h" #include "leveldb/db.h" diff --git a/port/port_win.h b/port/port_win.h index e8bf46ef27cd68..989c15cd91d057 100644 --- a/port/port_win.h +++ b/port/port_win.h @@ -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 diff --git a/util/env_win.cc b/util/env_win.cc index d32c4e676c3fcd..3b4c92b66e081c 100644 --- a/util/env_win.cc +++ b/util/env_win.cc @@ -761,14 +761,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;