return out;
}
+ostream &operator<<( const FileData *d, ostream &o ) {
+ return operator<<( *d, o );
+}
+
ostream &operator<<( const FileData &d, ostream &o ) {
o << d.getFileType() << ' ';
o << d.getPermissions() << ' ';
return o;
}
+istream &operator>>( istream &i, FileData *d ) {
+ return operator>>( i, *d );
+}
+
istream &operator>>( istream &i, FileData &d ) {
string file_string;
std::string filename;
};
-std::ostream &operator<<( const FileData &d, std::ostream &o );
+std::ostream &operator<<( const FileData *d, std::ostream &o );
+std::istream &operator>>( std::istream &i, FileData *d );
+std::ostream &operator<<( const FileData &d, std::ostream &o );
std::istream &operator>>( std::istream &i, FileData &d );
struct FileDataLastBackupCmp {
unsigned long long block_size = 512ULL;
- bool finished = true;
+ bool complete = true;
// Copy files over until full or out of files
file_vector::reverse_iterator i = backups_bysize.rbegin();
bytes_available -= blocks;
final_set.insert( *i );
} else {
- finished = false;
+ // We missed a file that should be included so the backup is not complete
+ complete = false;
}
++i;
}
}
// Write the 'current' list to the dbfile
+ ofstream dbout( "test.db" );
+ copy( current.begin(), current.end(), ostream_iterator<FileData*>( dbout, "" ) );
+
// Write the 'final_set' list to stdout
+ copy( final_set.begin(), final_set.end(), ostream_iterator<FileData*>( cout, "" ) );
- // If ! finished then write a flag to /tmp
+ // If ! complete then write a flag to /tmp
+ if( ! complete ) {
+ cerr << "incomplete" << endl;
+ }
// Clean-up
for( file_set::iterator i = backed_up.begin(); i != backed_up.end(); ++i ) { delete *i; }