From: Carl N Baldwin Date: Thu, 20 Oct 2005 04:21:34 +0000 (-0600) Subject: I think its about done X-Git-Tag: release-0.4~95 X-Git-Url: http://git.pippins.net/embedvideo/.git/%22%22.%24thumbnail.%22/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/static/gitweb.css?a=commitdiff_plain;h=7f34d8dde0bb8e00ab0955a977899f6104796c29;p=backups%2F.git I think its about done --- diff --git a/filedata.cpp b/filedata.cpp index 2a9840a..2669b75 100644 --- a/filedata.cpp +++ b/filedata.cpp @@ -43,6 +43,10 @@ vector split( const string &line, char c, int limit = -1 ) { 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() << ' '; @@ -56,6 +60,10 @@ ostream &operator<<( const FileData &d, ostream &o ) { return o; } +istream &operator>>( istream &i, FileData *d ) { + return operator>>( i, *d ); +} + istream &operator>>( istream &i, FileData &d ) { string file_string; diff --git a/filedata.hpp b/filedata.hpp index 47a2690..9d71f8c 100644 --- a/filedata.hpp +++ b/filedata.hpp @@ -50,8 +50,10 @@ class FileData { 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 { diff --git a/main.cc b/main.cc index 50bf703..079252e 100644 --- a/main.cc +++ b/main.cc @@ -91,7 +91,7 @@ int main() { 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(); @@ -103,7 +103,8 @@ int main() { 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; } @@ -143,9 +144,16 @@ int main() { } // Write the 'current' list to the dbfile + ofstream dbout( "test.db" ); + copy( current.begin(), current.end(), ostream_iterator( dbout, "" ) ); + // Write the 'final_set' list to stdout + copy( final_set.begin(), final_set.end(), ostream_iterator( 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; }