Skip to content

Commit

Permalink
Fixes to allow building with msvc.
Browse files Browse the repository at this point in the history
  • Loading branch information
sipsorcery committed Oct 24, 2017
1 parent c521b3a commit d6eab93
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 @@ -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;
Expand Down

0 comments on commit d6eab93

Please sign in to comment.