From: Carl N Baldwin Date: Mon, 17 Oct 2005 03:24:29 +0000 (-0600) Subject: Just a regular commit X-Git-Tag: release-0.4~107 X-Git-Url: http://git.pippins.net/embedvideo/images/static/%7Badd%7D?a=commitdiff_plain;h=10f79645bbc320f9b1375e7143079c953f63ab23;p=backups%2F.git Just a regular commit --- diff --git a/filedata.cpp b/filedata.cpp index 44b2860..c66dadc 100644 --- a/filedata.cpp +++ b/filedata.cpp @@ -10,11 +10,14 @@ FileData::FileData( char _type, string _group, unsigned long _size, unsigned long long _modified_date, - string _name ) + string _name, + unsigned long long _last_backup ) : filetype( _type ), permissions( _permissions ), username( _user ), groupname( _group ), filesize( _size ), modified_date( _modified_date ), - filename( _name ) {} + filename( _name ), + last_backup_date( _last_backup ) +{} diff --git a/filedata.hpp b/filedata.hpp index 86e5b0e..123ef86 100644 --- a/filedata.hpp +++ b/filedata.hpp @@ -1,3 +1,6 @@ +#ifndef FILEDATA_H +#define FILEDATA_H + #include class FileData { @@ -9,9 +12,14 @@ class FileData { std::string, unsigned long, unsigned long long, - std::string + std::string, + unsigned long long = 0 ); + char getFileType() const { return filetype; } + + const std::string &getFileName() const { return filename; } + private: FileData(); FileData( const FileData & ); @@ -26,3 +34,15 @@ class FileData { unsigned long long last_backup_date; }; + +class FileDataPtrCmp { + public: + + bool operator()( const FileData *a, const FileData *b ) { + return cmp( a->getFileName(), b->getFileName() ); + } + private: + std::less cmp; +}; + +#endif diff --git a/main.cc b/main.cc index dbd96a0..8ffd418 100644 --- a/main.cc +++ b/main.cc @@ -3,9 +3,12 @@ #include #include #include +#include #include +#include "filedata.hpp" + using namespace std; vector split( const string &line, char c, int limit = -1 ) { @@ -58,19 +61,29 @@ void sql_experimenting() { } 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; + set current_files; + + // 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 vals = split( file_string, ' ', 7 ); + current_files.insert( new FileData( vals[0][0], + vals[1], + vals[2], + vals[3], + atoi( vals[4].c_str() ), + atoi( vals[5].c_str() ), + vals[6]) ); + } + } while( ! cin.eof() ); - sql_experimenting(); + set previous_files; }