From 4f9fae9bb708ebd5b141b7b19f95a060a58390e6 Mon Sep 17 00:00:00 2001 From: Donovan Hide Date: Sun, 27 Apr 2014 20:57:10 +0100 Subject: [PATCH] Add rocksdb_open_for_read_only to C API --- db/c.cc | 14 ++++++++++++++ include/rocksdb/c.h | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/db/c.cc b/db/c.cc index 915a3e80e..b50e59ecc 100644 --- a/db/c.cc +++ b/db/c.cc @@ -330,6 +330,20 @@ rocksdb_t* rocksdb_open( return result; } +rocksdb_t* rocksdb_open_for_read_only( + const rocksdb_options_t* options, + const char* name, + unsigned char error_if_log_file_exist, + char** errptr) { + DB* db; + if (SaveError(errptr, DB::OpenForReadOnly(options->rep, std::string(name), &db, error_if_log_file_exist))) { + return nullptr; + } + rocksdb_t* result = new rocksdb_t; + result->rep = db; + return result; +} + void rocksdb_close(rocksdb_t* db) { delete db->rep; delete db; diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 7f2c082d0..013ee5d2a 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -83,6 +83,12 @@ extern rocksdb_t* rocksdb_open( const char* name, char** errptr); +extern rocksdb_t* rocksdb_open_for_read_only( + const rocksdb_options_t* options, + const char* name, + unsigned char error_if_log_file_exist, + char** errptr); + extern void rocksdb_close(rocksdb_t* db); extern void rocksdb_put(