X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;ds=sidebyside;f=filedata.hpp;h=f98b520e5e8d18eef6d2bf79b3a0c58ab181e0eb;hb=8973f8a61994c0e28fce64a3dc688d1e5f438d42;hp=629f933493bffcc733a44cfbfc5c89d2bc2bef75;hpb=3c9f7ebe59658ae9e45267bf01782a0864c77d48;p=backups%2F.git diff --git a/filedata.hpp b/filedata.hpp index 629f933..f98b520 100644 --- a/filedata.hpp +++ b/filedata.hpp @@ -3,49 +3,78 @@ #include #include +#include +#include class FileData { public: // Construct a FileData object with default values - FileData( char, - std::string, - std::string, - std::string, - unsigned long, - unsigned long long, - std::string, - unsigned long long = 0 - ); + FileData() {} - char getFileType() const { return filetype; } + 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; } - const std::string &getFileName() const { return filename; } + 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; } + + struct LastBackupCmp { + bool operator()( const FileData *a, const FileData *b ) { + return a->getLastBackupDate() < b->getLastBackupDate(); + } + }; + + struct SizeCmp { + bool operator()( const FileData *a, const FileData *b ) { + return a->getFileSize() < b->getFileSize(); + } + }; + + struct NameCmp { + bool operator()( const FileData *a, const FileData *b ) { + return cmp( a->getFileName(), b->getFileName() ); + } + private: + std::less cmp; + }; + + static const LastBackupCmp lastbackupcmp; + static const SizeCmp sizecmp; + static const NameCmp namecmp; private: - FileData(); FileData( const FileData & ); char filetype; std::string permissions; std::string username; std::string groupname; - unsigned long filesize; + unsigned long long filesize; unsigned long long modified_date; - std::string filename; - unsigned long long last_backup_date; + std::string filename; }; -class FileDataPtrCmp { - public: +std::ostream &operator<<( std::ostream &o, const FileData *d ); +std::istream &operator>>( std::istream &i, FileData *d ); - bool operator()( const FileData *a, const FileData *b ) { - return cmp( a->getFileName(), b->getFileName() ); - } - private: - std::less cmp; -}; +std::ostream &operator<<( std::ostream &o, const FileData &d ); +std::istream &operator>>( std::istream &i, FileData &d ); + +bool needs_backup( const FileData *before, const FileData *after ); -typedef std::set file_set; +typedef std::set file_set; +typedef std::vector file_vector; #endif