From ccca2f6414235e7aabba20c005d6678302633a78 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Sun, 4 Mar 2012 11:12:24 +0000 Subject: [PATCH] teach SSQLite3 class to also be able to generate a new sqlite3 database if so requested git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2449 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- modules/gsqlite3backend/ssqlite3.cc | 7 ++++--- modules/gsqlite3backend/ssqlite3.hh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/gsqlite3backend/ssqlite3.cc b/modules/gsqlite3backend/ssqlite3.cc index c59e996e6..a033f8384 100644 --- a/modules/gsqlite3backend/ssqlite3.cc +++ b/modules/gsqlite3backend/ssqlite3.cc @@ -18,11 +18,12 @@ #endif // Unix // Constructor. -SSQLite3::SSQLite3( const std::string & database ) +SSQLite3::SSQLite3( const std::string & database, bool creat ) { // Open the database connection. - if ( access( database.c_str(), F_OK ) == -1 ) - throw sPerrorException( "SQLite database does not exist yet" ); + if(!creat) + if ( access( database.c_str(), F_OK ) == -1 ) + throw sPerrorException( "SQLite database does not exist yet" ); if ( sqlite3_open( database.c_str(), &m_pDB)!=SQLITE_OK ) throw sPerrorException( "Could not connect to the SQLite database '" + database + "'" ); diff --git a/modules/gsqlite3backend/ssqlite3.hh b/modules/gsqlite3backend/ssqlite3.hh index d7539dcfa..7b3c3cf11 100644 --- a/modules/gsqlite3backend/ssqlite3.hh +++ b/modules/gsqlite3backend/ssqlite3.hh @@ -23,7 +23,7 @@ private: protected: public: //! Constructor. - SSQLite3( const std::string & database ); + SSQLite3( const std::string & database, bool creat=false ); //! Destructor. ~SSQLite3(); -- 2.49.0