// Sets the current directory to the home dir
mCurrentDirectory = GetHomeDirectory();
mSynchronizer=0;
+
// Create local database handler
mLocalDatabase = new SQLiteTreeHandler(GetLocalDatabasePath());
// Add it to the TreeHandlerMap
mTreeHandlerMap["Local database"] = mLocalDatabase;
-
// Create or open local database
if (! boost::filesystem::exists( GetLocalDatabasePath() ) )
{
}
}
+
+
+ // Creates files and directories database
+ mTimestampDatabase = new TimestampDatabaseHandler(GetTimestampDatabasePath());
+ // Create or open local database
+ if (! boost::filesystem::exists( GetTimestampDatabasePath() ) )
+ {
+ std::string mess = "Timestamp database '";
+ mess += GetTimestampDatabasePath();
+ mess += "' does not exist : creating it";
+ GimmickMessage(1,mess<<std::endl);
+
+ if ( ! mTimestampDatabase->Create() )
+ {
+ GimmickError("ERROR CREATING '"<<GetTimestampDatabasePath()<<"'");
+ }
+
+ }
+ else
+ {
+ /// Open and test it
+ GimmickMessage(1,"Opening Timestamp database '"
+ <<GetTimestampDatabasePath()<<"' "
+ <<std::endl);
+ if ( ! mTimestampDatabase->Open() )
+ {
+ GimmickError("ERROR OPENING '"<<GetTimestampDatabasePath()<<"'");
+ }
+
+ }
+
}
//================================================================
void Gimmick::Finalize()
{
delete mLocalDatabase;
+ delete mTimestampDatabase;
}
//==============================================================
}
return mLocalDatabasePath;
}
+
+ //================================================================
+
+ //================================================================
+ const std::string& Gimmick::GetTimestampDatabasePath()
+ {
+ if (mTimestampDatabasePath.size()==0)
+ {
+ mTimestampDatabasePath = GetUserSettingsDirectory();
+ mTimestampDatabasePath += "timestamp_database.sqlite3";
+ boost::algorithm::replace_all( mTimestampDatabasePath,
+ INVALID_FILE_SEPARATOR ,
+ VALID_FILE_SEPARATOR);
+ }
+ return mTimestampDatabasePath;
+ }
//========================================================================
//========================================================================
//========================================================================
//========================================================================
- /// Add a file to the local database
+ /// Returns the tree handler with the given name
TreeHandler* Gimmick::GetTreeHandler(const std::string& name) const
{
TreeHandlerMapType::const_iterator i;
return i->second;
}
+ //========================================================================
+ ///Returns the timestamp database handler
+ TimestampDatabaseHandler* Gimmick::GetTimestampDatabase() const
+ {
+ return mTimestampDatabase;
+ }
+
//========================================================================
/// Add the files to the tree handler
GimmickMessage(2,"Adding files to '"<<d<<"'"<<std::endl);
mImageAdder.SetTreeHandler(GetTreeHandler(d));
+ mImageAdder.SetTimestampHandler(mTimestampDatabase);
mImageAdder.AddFiles(filenames);
}
TreeHandler * handler=GetTreeHandler(d);
mImageAdder.SetTreeHandler(handler);
+ mImageAdder.SetTimestampHandler(mTimestampDatabase);
mImageAdder.AddDirectory(f,recurse);
//Synchronize(true, handler);