|
|
|
@ -3,6 +3,7 @@ extern crate lmdb_sys; |
|
|
|
|
use lmdb_sys::*; |
|
|
|
|
|
|
|
|
|
use std::ffi::{c_void, CString}; |
|
|
|
|
use std::fs::File; |
|
|
|
|
use std::ptr; |
|
|
|
|
|
|
|
|
|
// https://github.com/victorporof/lmdb/blob/mdb.master/libraries/liblmdb/moz-test.c
|
|
|
|
@ -34,6 +35,18 @@ fn test_simple_64() { |
|
|
|
|
test_simple("./tests/fixtures/testdb") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg(windows)] |
|
|
|
|
fn get_file_fd(file: &File) -> std::os::windows::io::RawHandle { |
|
|
|
|
use std::os::windows::io::AsRawHandle; |
|
|
|
|
file.as_raw_handle() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg(unix)] |
|
|
|
|
fn get_file_fd(file: &File) -> std::os::unix::io::RawFd { |
|
|
|
|
use std::os::unix::io::AsRawFd; |
|
|
|
|
file.as_raw_fd() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn test_simple(env_path: &str) { |
|
|
|
|
let mut env: *mut MDB_env = ptr::null_mut(); |
|
|
|
|
let mut dbi: MDB_dbi = 0; |
|
|
|
@ -66,6 +79,13 @@ fn test_simple(env_path: &str) { |
|
|
|
|
E!(mdb_txn_begin(env, ptr::null_mut(), 0, &mut txn)); |
|
|
|
|
E!(mdb_put(txn, dbi, &mut key, &mut data, 0)); |
|
|
|
|
E!(mdb_txn_commit(txn)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let file = File::create("./tests/fixtures/copytestdb.mdb").unwrap(); |
|
|
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
let fd = get_file_fd(&file); |
|
|
|
|
E!(mdb_env_copyfd(env, fd)); |
|
|
|
|
|
|
|
|
|
mdb_dbi_close(env, dbi); |
|
|
|
|
mdb_env_close(env); |
|
|
|
|