X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=filedata.hpp;h=b339f05f92b2fcc4c425e13c119b56bbb37a8a5b;hb=670cdf5e409d54d252af355aa2ee42d5b67d8860;hp=0393ecd69c159ceb4d88ef53e6dfddfe4dd123b6;hpb=c1af9697acaf6dbc98afa5ffe18d2c5c7ab12c59;p=backups%2F.git diff --git a/filedata.hpp b/filedata.hpp index 0393ecd..b339f05 100644 --- a/filedata.hpp +++ b/filedata.hpp @@ -1,26 +1,76 @@ +#ifndef FILEDATA_H +#define FILEDATA_H + #include +#include +#include +#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 - ); + FileData() {} + + char getFileType() const { return filetype; } + const std::string &getPermissions() const { return permissions; } + const std::string &getUserName() const { return username; } + const std::string &getGroupName() const { return groupname; } + unsigned long long getFileSize() const { return filesize; } + unsigned long long getModifiedDate() const { return modified_date; } + const std::string &getFileName() const { return filename; } + unsigned long long getLastBackupDate() const { return last_backup_date; } + + void setFileType( char arg ) { filetype = arg; } + void setPermissions( const std::string &arg ) { permissions = arg; } + void setUserName( const std::string &arg ) { username = arg; } + void setGroupName( const std::string &arg ) { groupname = arg; } + void setFileSize( unsigned long long arg ) { filesize = arg; } + void setModifiedDate( unsigned long long arg ) { modified_date = arg; } + void setFileName( const std::string &arg ) { filename = arg; } + void setLastBackupDate( unsigned long long arg ) { last_backup_date = arg; } private: - FileData(); FileData( const FileData & ); - char type; + char filetype; std::string permissions; - std::string user; - std::string group; - unsigned int size; + std::string username; + std::string groupname; + unsigned long long filesize; unsigned long long modified_date; - std::string name; + unsigned long long last_backup_date; + std::string filename; +}; + +std::ostream &operator<<( std::ostream &o, const FileData *d ); +std::istream &operator>>( std::istream &i, FileData *d ); + +std::ostream &operator<<( std::ostream &o, const FileData &d ); +std::istream &operator>>( std::istream &i, FileData &d ); + +struct FileDataLastBackupCmp { + bool operator()( const FileData *a, const FileData *b ) { + return a->getLastBackupDate() < b->getLastBackupDate(); + } }; + +struct FileDataSizeCmp { + bool operator()( const FileData *a, const FileData *b ) { + return a->getFileSize() < b->getFileSize(); + } +}; + +struct FileDataNameCmp { + bool operator()( const FileData *a, const FileData *b ) { + return cmp( a->getFileName(), b->getFileName() ); + } + private: + std::less cmp; +}; + +bool needs_backup( const FileData *before, const FileData *after ); + +typedef std::set file_set; +typedef std::vector file_vector; + +#endif