Initial stuff for sqllite version of object-db. Changing to boost::filesystem
diff --git a/src/db-helper.cc b/src/db-helper.cc
index 217c3ee..c5455e8 100644
--- a/src/db-helper.cc
+++ b/src/db-helper.cc
@@ -26,6 +26,7 @@
#include <boost/throw_exception.hpp>
using namespace boost;
+namespace fs = boost::filesystem;
const std::string INIT_DATABASE = "\
PRAGMA foreign_keys = ON; \n\
@@ -162,13 +163,16 @@
CREATE INDEX FileState_device_id_seq_no ON FileState (device_id, seq_no); \n\
";
-DbHelper::DbHelper (const std::string &path)
+DbHelper::DbHelper (const fs::path &path)
{
- int res = sqlite3_open((path+"chronoshare.db").c_str (), &m_db);
+ fs::path chronoshareDirectory = path / ".chronoshare";
+ fs::create_directories (chronoshareDirectory);
+
+ int res = sqlite3_open((chronoshareDirectory / "state.db").c_str (), &m_db);
if (res != SQLITE_OK)
{
BOOST_THROW_EXCEPTION (Error::Db ()
- << errmsg_info_str ("Cannot open/create dabatabase: [" + path + "chronoshare.db" + "]"));
+ << errmsg_info_str ("Cannot open/create dabatabase: [" + (chronoshareDirectory / "state.db").string () + "]"));
}
res = sqlite3_create_function (m_db, "hash", 2, SQLITE_ANY, 0, 0,