Skip to content

Commit d6eab93

Browse files
committed
Fixes to allow building with msvc.
1 parent c521b3a commit d6eab93

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

db/c.cc

Lines changed: 2 additions & 0 deletions
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

Lines changed: 7 additions & 0 deletions
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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,14 +761,16 @@ uint64_t Win32Env::NowMicros()
761761
static Status CreateDirInner( const std::string& dirname )
762762
{
763763
Status sRet;
764-
DWORD attr = ::GetFileAttributes(dirname.c_str());
764+
std::wstring dirnameW;
765+
ToWidePath(dirname, dirnameW);
766+
DWORD attr = ::GetFileAttributesW(dirnameW.c_str());
765767
if (attr == INVALID_FILE_ATTRIBUTES) { // doesn't exist:
766768
std::size_t slash = dirname.find_last_of("\\");
767769
if (slash != std::string::npos){
768770
sRet = CreateDirInner(dirname.substr(0, slash));
769771
if (!sRet.ok()) return sRet;
770772
}
771-
BOOL result = ::CreateDirectory(dirname.c_str(), NULL);
773+
BOOL result = ::CreateDirectoryW(dirnameW.c_str(), NULL);
772774
if (result == FALSE) {
773775
sRet = Status::IOError(dirname, "Could not create directory.");
774776
return sRet;

0 commit comments

Comments
 (0)