Commit 4766f0b7 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

changed the method used to create directories

parent d8d46ea2
// Copyright (c) 2017, Los Alamos National Security, LLC.
// All rights reserved.
#include "berkeleydb_datastore.h"
#include "fs_util.h"
#include "kv-config.h"
#include <sstream>
#include <chrono>
......@@ -31,9 +32,10 @@ void BerkeleyDBDataStore::createDatabase(const std::string& db_name, const std::
int status = 0;
if (!db_path.empty()) {
std::stringstream str_db_path("mkdir -p ");
str_db_path << db_path;
system(str_db_path.str().c_str());
//std::stringstream str_db_path("mkdir -p ");
//str_db_path << db_path;
//system(str_db_path.str().c_str());
mkdirs(db_path.c_str());
}
// initialize the environment
......
#ifndef __FS_UTIL
#define __FS_UTIL
#include <sys/stat.h>
#include <limits.h>
inline void mkdirs(const char *dir) {
char tmp[256];
char *p = NULL;
size_t len;
len = snprintf(tmp, sizeof(tmp),"%s",dir);
if(tmp[len - 1] == '/')
tmp[len - 1] = 0;
for(p = tmp + 1; *p; p++)
if(*p == '/') {
*p = 0;
mkdir(tmp, S_IRWXU);
*p = '/';
}
mkdir(tmp, S_IRWXU);
}
#endif
// Copyright (c) 2017, Los Alamos National Security, LLC.
// All rights reserved.
#include "leveldb_datastore.h"
#include "fs_util.h"
#include "kv-config.h"
#include <cstring>
#include <chrono>
......@@ -39,9 +40,10 @@ void LevelDBDataStore::createDatabase(const std::string& db_name, const std::str
leveldb::Status status;
if (!db_path.empty()) {
std::stringstream str_db_path("mkdir -p ");
str_db_path << db_path;
system(str_db_path.str().c_str());
// std::stringstream str_db_path("mkdir -p ");
// str_db_path << db_path;
// system(str_db_path.str().c_str());
mkdirs(db_path.c_str());
}
options.comparator = &_keycmp;
options.create_if_missing = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment