aboutsummaryrefslogtreecommitdiff
path: root/ports/leveldb/msvc_code_fix.diff
blob: 6cab006d34a43bb97a03db4e804d7655307958d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 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 08ff0ad..b23e3dc 100644
--- a/db/c.cc
+++ b/db/c.cc
@@ -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"
diff --git a/port/port_win.h b/port/port_win.h
index e8bf46e..989c15c 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 <string>
diff --git a/util/env_win.cc b/util/env_win.cc
index d32c4e6..3b4c92b 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;