- // Parse the list of files on stdin
- 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<string> vals = split( file_string, ' ', 7 );
- current.insert( new FileData( vals[0][0],
- vals[1],
- vals[2],
- vals[3],
- atoi( vals[4].c_str() ),
- atoi( vals[5].c_str() ),
- vals[6]) );
+ file_set backed_up;
+ ifstream db( "test.db" );
+ populate_set( db, backed_up);
+
+ // Now divide the two sets into three sets (added, deleted and common )
+ file_set added, deleted, common;
+ partition_sets( current, backed_up, added, common, deleted );
+
+ { // This little block will copy the last_backup_date from the second set to the first
+ FileDataNameCmp cmp;
+
+ file_set updated_mirror;
+ set_union( current.begin(), current.end(),
+ backed_up.begin(), backed_up.end(),
+ inserter( updated_mirror, updated_mirror.begin() ),
+ cmp );
+
+ // TODO Now we need to copy the last_backup_date from
+ file_set::iterator i = common.begin(), j = updated_mirror.begin();
+ for( ; i != common.end(); ++i, ++j ) {
+ (*i)->setLastBackupDate( (*j)->getLastBackupDate() );