Skip to content

Commit

Permalink
Add rocksdb_open_for_read_only to C API
Browse files Browse the repository at this point in the history
  • Loading branch information
Donovan Hide committed Apr 27, 2014
1 parent fe331c8 commit 4f9fae9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions include/rocksdb/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4f9fae9

Please sign in to comment.