tweaks to enable windows builds with msvc (#9)

without.crypto
Chip Collier 9 years ago committed by Dan Burkert
parent 9b5d48c89a
commit 0d20eb4b59
  1. 2
      lmdb-sys/src/ffi.rs
  2. 7
      lmdb-sys/src/lib.rs
  3. 19
      src/environment.rs

@ -62,7 +62,7 @@ extern "C" {
pub fn mdb_version(major: *mut ::libc::c_int, minor: *mut ::libc::c_int, patch: *mut ::libc::c_int) -> *mut ::libc::c_char;
pub fn mdb_strerror(err: ::libc::c_int) -> *mut ::libc::c_char;
pub fn mdb_env_create(env: *mut *mut MDB_env) -> ::libc::c_int;
pub fn mdb_env_open(env: *mut MDB_env, path: *const ::libc::c_char, flags: ::libc::c_uint, mode: ::libc::mode_t) -> ::libc::c_int;
pub fn mdb_env_open(env: *mut MDB_env, path: *const ::libc::c_char, flags: ::libc::c_uint, mode: super::mode_t) -> ::libc::c_int;
pub fn mdb_env_copy(env: *mut MDB_env, path: *const ::libc::c_char) -> ::libc::c_int;
pub fn mdb_env_copyfd(env: *mut MDB_env, fd: ::libc::c_int) -> ::libc::c_int;
pub fn mdb_env_copy2(env: *mut MDB_env, path: *const ::libc::c_char, flags: ::libc::c_uint) -> ::libc::c_int;

@ -2,6 +2,13 @@
extern crate libc;
#[cfg(unix)]
#[allow(non_camel_case_types)]
pub type mode_t = ::libc::mode_t;
#[cfg(windows)]
#[allow(non_camel_case_types)]
pub type mode_t = ::libc::c_int;
pub use constants::*;
pub use ffi::*;

@ -1,6 +1,9 @@
use libc::{c_uint, size_t, mode_t};
use libc::{c_uint, size_t};
use std::ffi::CString;
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
#[cfg(windows)]
use std::ffi::OsStr;
use std::path::Path;
use std::ptr;
use std::sync::Mutex;
@ -12,6 +15,18 @@ use database::Database;
use transaction::{RoTransaction, RwTransaction, Transaction};
use flags::{DatabaseFlags, EnvironmentFlags};
#[cfg(windows)]
/// Adding a 'missing' trait from windows OsStrExt
trait OsStrExtLmdb {
fn as_bytes(&self) -> &[u8];
}
#[cfg(windows)]
impl OsStrExtLmdb for OsStr {
fn as_bytes(&self) -> &[u8] {
&self.to_str().unwrap().as_bytes()
}
}
/// An LMDB environment.
///
/// An environment supports multiple databases, all residing in the same shared-memory map.
@ -176,7 +191,7 @@ impl EnvironmentBuilder {
/// On Windows, the permissions will be ignored.
///
/// The path may not contain the null character.
pub fn open_with_permissions(&self, path: &Path, mode: mode_t) -> Result<Environment> {
pub fn open_with_permissions(&self, path: &Path, mode: ffi::mode_t) -> Result<Environment> {
let mut env: *mut ffi::MDB_env = ptr::null_mut();
unsafe {
lmdb_try!(ffi::mdb_env_create(&mut env));

Loading…
Cancel
Save