EXTRA_DIST = $(bin_SCRIPTS)
-lsbackups_SOURCES = main.cc
+lsbackups_SOURCES = main.cc \
+ filedata.hpp \
+ filedata.cpp
AM_CPPFLAGS = $(SQLITE3_CFLAGS)
LDADD = $(SQLITE3_LIBS)
--- /dev/null
+#include <string>
+
+#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 ) {}
--- /dev/null
+#include <string>
+
+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;
+};
#include <iostream>
+#include <iterator>
+#include <string>
+#include <vector>
#include <algorithm>
using namespace std;
+vector<string> split( const string &line, char c, int limit = -1 ) {
+ string::size_type start = 0, end = 0;
+
+ vector<string> 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 {
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<string> values = split( file_string, ' ', 7 );
}
} while( ! cin.eof() );
}