From 7f34d8dde0bb8e00ab0955a977899f6104796c29 Mon Sep 17 00:00:00 2001
From: Carl N Baldwin <cnb@plane.(none)>
Date: Wed, 19 Oct 2005 22:21:34 -0600
Subject: [PATCH] I think its about done

---
 filedata.cpp |  8 ++++++++
 filedata.hpp |  4 +++-
 main.cc      | 14 +++++++++++---
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/filedata.cpp b/filedata.cpp
index 2a9840a..2669b75 100644
--- a/filedata.cpp
+++ b/filedata.cpp
@@ -43,6 +43,10 @@ vector<string> 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<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; }
-- 
2.34.1