mirror of https://github.com/vitalif/grive2
remove Gdbm stuff as it won't compile on some system
parent
c01ace7d18
commit
3c769a720a
|
@ -71,6 +71,7 @@ target_link_libraries( grive
|
|||
${Boost_LIBRARIES}
|
||||
${OPT_LIBS}
|
||||
expat
|
||||
stdc++
|
||||
)
|
||||
|
||||
set_target_properties(grive PROPERTIES
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
grive: an GPL program to sync a local directory with Google Drive
|
||||
Copyright (C) 2012 Wan Wai Ho
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation version 2
|
||||
of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "Gdbm.hh"
|
||||
|
||||
#include <boost/exception/all.hpp>
|
||||
|
||||
#include <gdbm.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace gr {
|
||||
|
||||
struct Gdbm::Impl
|
||||
{
|
||||
GDBM_FILE db ;
|
||||
} ;
|
||||
|
||||
Gdbm::Gdbm( const std::string& filename ) :
|
||||
m_impl( new Impl )
|
||||
{
|
||||
std::string str( filename ) ;
|
||||
m_impl->db = ::gdbm_open( &str[0], 4096, GDBM_WRCREAT, 0600, &Gdbm::OnError ) ;
|
||||
if ( m_impl->db == 0 )
|
||||
{
|
||||
char *msg = gdbm_strerror(gdbm_errno) ;
|
||||
BOOST_THROW_EXCEPTION( Error() << expt::ErrMsg( msg ) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
Gdbm::~Gdbm()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Gdbm::Get( const std::string& key ) const
|
||||
{
|
||||
std::string ckey = key ;
|
||||
datum dkey = { &ckey[0], ckey.size() } ;
|
||||
datum val = gdbm_fetch( m_impl->db, dkey ) ;
|
||||
|
||||
std::string result ;
|
||||
if ( val.dptr != 0 )
|
||||
{
|
||||
result.append( val.dptr, val.dsize ) ;
|
||||
::free( val.dptr ) ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
void Gdbm::Set( const std::string& key, const std::string& val )
|
||||
{
|
||||
assert( m_impl->db != 0 ) ;
|
||||
|
||||
std::string ckey = key, cval = val ;
|
||||
datum dkey = { &ckey[0], ckey.size() } ;
|
||||
datum dval = { &cval[0], cval.size() } ;
|
||||
|
||||
gdbm_store( m_impl->db, dkey, dval, GDBM_REPLACE ) ;
|
||||
}
|
||||
|
||||
void Gdbm::OnError( )
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( Error() << expt::ErrMsg( gdbm_strerror(gdbm_errno) ) ) ;
|
||||
}
|
||||
|
||||
} // end of namespace
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
grive: an GPL program to sync a local directory with Google Drive
|
||||
Copyright (C) 2012 Wan Wai Ho
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation version 2
|
||||
of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Exception.hh"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace gr {
|
||||
|
||||
class Gdbm
|
||||
{
|
||||
public :
|
||||
struct Error : virtual Exception {} ;
|
||||
|
||||
public :
|
||||
explicit Gdbm( const std::string& filename ) ;
|
||||
~Gdbm() ;
|
||||
|
||||
std::string Get( const std::string& key ) const ;
|
||||
void Set( const std::string& key, const std::string& val ) ;
|
||||
|
||||
private :
|
||||
static void OnError( ) ;
|
||||
|
||||
private :
|
||||
struct Impl ;
|
||||
std::auto_ptr<Impl> m_impl ;
|
||||
} ;
|
||||
|
||||
} // end of namespace
|
|
@ -38,7 +38,7 @@ public :
|
|||
~StdioFile( ) ;
|
||||
|
||||
void Open( const std::string& filename, const char *mode ) ;
|
||||
void Open( const boost::filesystem3::path& path, const char* mode ) ;
|
||||
void Open( const fs::path& path, const char* mode ) ;
|
||||
void Close() ;
|
||||
bool IsOpened() const ;
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "drive/StateTest.hh"
|
||||
#include "util/DateTimeTest.hh"
|
||||
#include "util/FunctionTest.hh"
|
||||
#include "util/GdbmTest.hh"
|
||||
#include "util/SignalHandlerTest.hh"
|
||||
#include "xml/NodeTest.hh"
|
||||
|
||||
|
@ -45,7 +44,6 @@ int main( int argc, char **argv )
|
|||
runner.addTest( DateTimeTest::suite( ) ) ;
|
||||
runner.addTest( FunctionTest::suite( ) ) ;
|
||||
runner.addTest( SignalHandlerTest::suite( ) ) ;
|
||||
runner.addTest( GdbmTest::suite( ) ) ;
|
||||
runner.addTest( NodeTest::suite( ) ) ;
|
||||
runner.run();
|
||||
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
grive: an GPL program to sync a local directory with Google Drive
|
||||
Copyright (C) 2012 Wan Wai Ho
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation version 2
|
||||
of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "GdbmTest.hh"
|
||||
|
||||
#include "Assert.hh"
|
||||
|
||||
#include "util/Gdbm.hh"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace grut {
|
||||
|
||||
using namespace gr ;
|
||||
|
||||
GdbmTest::GdbmTest( )
|
||||
{
|
||||
}
|
||||
|
||||
void GdbmTest::Test( )
|
||||
{
|
||||
{
|
||||
Gdbm db( "test.db" ) ;
|
||||
db.Set( "key", "value" ) ;
|
||||
GRUT_ASSERT_EQUAL( db.Get("key"), "value" ) ;
|
||||
}
|
||||
|
||||
// re-open and verify
|
||||
Gdbm db( "test.db" ) ;
|
||||
GRUT_ASSERT_EQUAL( db.Get("key"), "value" ) ;
|
||||
}
|
||||
|
||||
void GdbmTest::tearDown()
|
||||
{
|
||||
unlink( "test.db" ) ;
|
||||
}
|
||||
|
||||
} // end of namespace grut
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
grive: an GPL program to sync a local directory with Google Drive
|
||||
Copyright (C) 2012 Wan Wai Ho
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation version 2
|
||||
of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace grut {
|
||||
|
||||
class GdbmTest : public CppUnit::TestFixture
|
||||
{
|
||||
public :
|
||||
GdbmTest( ) ;
|
||||
|
||||
// declare suit function
|
||||
CPPUNIT_TEST_SUITE( GdbmTest ) ;
|
||||
CPPUNIT_TEST( Test ) ;
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public :
|
||||
void tearDown() ;
|
||||
|
||||
private :
|
||||
void Test( ) ;
|
||||
} ;
|
||||
|
||||
} // end of namespace
|
Loading…
Reference in New Issue