From: Carl N Baldwin Date: Sun, 16 Oct 2005 03:54:27 +0000 (-0600) Subject: Some more work. X-Git-Tag: release-0.4~111 X-Git-Url: http://git.pippins.net/embedvideo/.git/%22%22.%24thumbnail.%22/%7Bnolink%7D?a=commitdiff_plain;h=c1af9697acaf6dbc98afa5ffe18d2c5c7ab12c59;p=backups%2F.git Some more work. --- diff --git a/Makefile.am b/Makefile.am index d4632fe..a9d90e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,9 @@ bin_SCRIPTS = find-cmd.sh EXTRA_DIST = $(bin_SCRIPTS) -lsbackups_SOURCES = main.cc +lsbackups_SOURCES = main.cc \ + filedata.hpp \ + filedata.cpp AM_CPPFLAGS = $(SQLITE3_CFLAGS) LDADD = $(SQLITE3_LIBS) diff --git a/filedata.cpp b/filedata.cpp new file mode 100644 index 0000000..c3a8840 --- /dev/null +++ b/filedata.cpp @@ -0,0 +1,20 @@ +#include + +#include "filedata.hpp" + +using namespace std; + +FileData::FileData( char _type, + string _permissions, + string _user, + string _group, + unsigned int _size, + unsigned long long _modified_date, + string _name ) +: type( _type ), + permissions( _permissions ), + user( _user ), + group( _group ), + size( _size ), + modified_date( _modified_date ), + name( _name ) {} diff --git a/filedata.hpp b/filedata.hpp new file mode 100644 index 0000000..0393ecd --- /dev/null +++ b/filedata.hpp @@ -0,0 +1,26 @@ +#include + +class FileData { + public: + // Construct a FileData object with default values + FileData( char, + std::string, + std::string, + std::string, + unsigned int, + unsigned long long, + std::string + ); + + private: + FileData(); + FileData( const FileData & ); + + char type; + std::string permissions; + std::string user; + std::string group; + unsigned int size; + unsigned long long modified_date; + std::string name; +}; diff --git a/main.cc b/main.cc index bd744b6..b809f58 100644 --- a/main.cc +++ b/main.cc @@ -1,8 +1,30 @@ #include +#include +#include +#include #include using namespace std; +vector split( const string &line, char c, int limit = -1 ) { + string::size_type start = 0, end = 0; + + vector out; + while( 0 != limit-- && end != line.size() ) { + if( 0 == limit ) { + end = line.size(); + } else { + end = line.find( c, start ); + if( end == string::npos ) { + end = line.size(); + } + } + out.push_back( line.substr( start, end-start ) ); + start = end + 1; + } + return out; +} + int main() { string file_string; do { @@ -11,7 +33,10 @@ int main() { file_string.push_back( c ); } if( 0 != file_string.size() ) { - cout << file_string << endl; + // 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() ); }