From: Carl N Baldwin Date: Mon, 17 Oct 2005 02:26:34 +0000 (-0600) Subject: Just a regular commit X-Git-Tag: release-0.4~108 X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=commitdiff_plain;h=b6878571e12b7d5de53721f12e8fb956d07e44d6;p=backups%2F.git Just a regular commit --- diff --git a/filedata.cpp b/filedata.cpp index c3a8840..44b2860 100644 --- a/filedata.cpp +++ b/filedata.cpp @@ -8,13 +8,13 @@ FileData::FileData( char _type, string _permissions, string _user, string _group, - unsigned int _size, + unsigned long _size, unsigned long long _modified_date, string _name ) -: type( _type ), +: filetype( _type ), permissions( _permissions ), - user( _user ), - group( _group ), - size( _size ), + username( _user ), + groupname( _group ), + filesize( _size ), modified_date( _modified_date ), - name( _name ) {} + filename( _name ) {} diff --git a/filedata.hpp b/filedata.hpp index 0393ecd..86e5b0e 100644 --- a/filedata.hpp +++ b/filedata.hpp @@ -7,7 +7,7 @@ class FileData { std::string, std::string, std::string, - unsigned int, + unsigned long, unsigned long long, std::string ); @@ -16,11 +16,13 @@ class FileData { FileData(); FileData( const FileData & ); - char type; + char filetype; std::string permissions; - std::string user; - std::string group; - unsigned int size; + std::string username; + std::string groupname; + unsigned long filesize; unsigned long long modified_date; - std::string name; + std::string filename; + + unsigned long long last_backup_date; }; diff --git a/main.cc b/main.cc index b809f58..dbd96a0 100644 --- a/main.cc +++ b/main.cc @@ -4,6 +4,8 @@ #include #include +#include + using namespace std; vector split( const string &line, char c, int limit = -1 ) { @@ -25,18 +27,50 @@ vector split( const string &line, char c, int limit = -1 ) { return out; } +int callback( void *NotUsed, int argc, char **argv, char **azColName ) { + int i; + for( int i = 0; i < argc; ++i ) { + cout << azColName[i] << " = " << ( argv[i] ? argv[i] : "NULL" ) << endl; + } + cout << endl; + return 0; +} + +void sql_experimenting() { + sqlite3 *db; + char *sqliteErrMsg = 0; + int rc; + + const char *dbname = "test.db"; + rc = sqlite3_open( dbname, &db ); + if( SQLITE_OK != rc ) { + cerr << "Cannot open database: " << dbname << ". Error message is..." << endl; + cerr << sqlite3_errmsg(db) << endl; + } + + rc = sqlite3_exec( db, "select * from filedata;", callback, 0, &sqliteErrMsg ); + if( SQLITE_OK != rc ) { + cerr << "Problem with database. Message is..." << endl; + cerr << sqliteErrMsg << endl; + } + + sqlite3_close( db ); +} + int main() { - string file_string; - do { - file_string.clear(); - for( int c = cin.get(); 0 != c && ! cin.eof(); c = cin.get() ) { - file_string.push_back( c ); - } - if( 0 != file_string.size() ) { - // Example entry - // type perms user group size datemodified name (7 total) - // f 0600 cnb cnb 424 20051015205340 ./.git/index - vector values = split( file_string, ' ', 7 ); - } - } while( ! cin.eof() ); +// string file_string; +// do { +// file_string.clear(); +// for( int c = cin.get(); 0 != c && ! cin.eof(); c = cin.get() ) { +// file_string.push_back( c ); +// } +// if( 0 != file_string.size() ) { +// // Example entry +// // type perms user group size datemodified name (7 total) +// // f 0600 cnb cnb 424 20051015205340 ./.git/index +// vector values = split( file_string, ' ', 7 ); +// } +// } while( ! cin.eof() ); + + sql_experimenting(); } diff --git a/schema.sql b/schema.sql index d1515d9..42bf811 100644 --- a/schema.sql +++ b/schema.sql @@ -1,9 +1,10 @@ -CREATE TABLE file ( - CHAR type, - VARCHAR permissions, - VARCHAR user, - VARCHAR group, - INTEGER size, - INTEGER modified_date, - VARCHAR name -) +CREATE TABLE filedata ( + filetype CHAR, + permissions VARCHAR, + username VARCHAR, + groupname VARCHAR, + filesize INTEGER, + modified_date INTEGER, -- e.g. 20051016194000 for Oct 10, 2005 at 7:40pm + filename VARCHAR, + last_backup_date INTEGER +);