#include <fileinfo.h>
Public Types | |
enum | FileStatus { FileStatusNotSet, FileOK, IgnoreFile, UncheckedFile } |
enum | FileType { TFile, TDirectory, TSymbolicLink, TNotDefined, TNotAvailable } |
Public Member Functions | |
FileInfo (Dedupe::FilePath PathToFile) | |
FileInfo (Dedupe::FilePath PathToFile, unsigned long long size, time_t ChangeDate, Dedupe::FileInfo::FileType Type, bool keep) | |
FileInfo (Dedupe::FilePath PathToFile, unsigned long long size, time_t ChangeDate, Dedupe::FileInfo::FileType Type, bool keep, unsigned long long HashValue) | |
Dedupe::FilePath | GetPath () const |
unsigned long long | GetSize () const |
time_t | GetDateChanged () const |
bool | GetExisting () const |
Dedupe::FileInfo::FileType | GetType () const |
void | SetHash (unsigned long long const &value) |
unsigned long long | GetHash () const |
void | SetStatus (FileStatus value) |
FileStatus | GetStatus () const |
void | SetErrorMessage (std::string const &message) |
std::string | GetErrorMessage () const |
bool | GetKeep () const |
void | SetKeep (bool YesNo) |
bool | operator< (const FileInfo &rhs) const |
Friends | |
bool | operator== (const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs) |
bool | operator!= (const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs) |
std::ostream & | operator<< (std::ostream &os, const Dedupe::FileInfo &Info) |
bool | EqualNoHash (const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs) |
This class represents a single file on the harddisk with all needed informations about the file.
Definition at line 32 of file fileinfo.h.
FileStatus says, if the file is trustable
FileStatusNotSet |
FileStatus is not set yet. |
FileOK |
File is OK, all infos are here. |
IgnoreFile |
File has Error, invalid data. |
UncheckedFile |
File Data is unchecked, don't trust! |
Definition at line 39 of file fileinfo.h.
{ FileStatusNotSet, FileOK, IgnoreFile, UncheckedFile };
FileType defines different filetypes which are detected and used in Dedupe
Definition at line 51 of file fileinfo.h.
{ TFile, TDirectory, TSymbolicLink, TNotDefined, TNotAvailable };
Dedupe::FileInfo::FileInfo | ( | Dedupe::FilePath | PathToFile | ) |
Use the filepath to construct this class constructor with Dedupe::FilePath (typedef of boost::filesystem::path)
Definition at line 10 of file fileinfo.cpp.
References SetErrorMessage().
: Path(""), Size( 0 ), DateChanged( 0 ), Existing( false ), Type( TNotAvailable ), Hash( 0 ), Keep( false ), StateOfFile( FileStatusNotSet ), FileSearchErrorMessage( "" ) { //Creates a portable path from a native path PathToFile.string(); //Make path absolute and set it after creation of the portable path format Path = boost::filesystem::absolute( PathToFile, boost::filesystem::current_path()); /*create a boost error_code for use in the following boost functions; We don't want Exceptions*/ boost::system::error_code ec; if( boost::filesystem::exists( Path, ec ) ) { if( ec != 0 ) { StateOfFile = IgnoreFile; SetErrorMessage( ec.message() ); } Existing = true; // Get the filestatus boost::filesystem::file_status FileStatus; FileStatus = boost::filesystem::symlink_status( Path, ec ); if( ec != 0 ) { StateOfFile = IgnoreFile; SetErrorMessage( ec.message() ); } if( boost::filesystem::is_regular_file( FileStatus ) ) { Size = boost::filesystem::file_size( Path ); DateChanged = boost::filesystem::last_write_time( Path ); Type = TFile; } if( boost::filesystem::is_symlink( FileStatus ) ) { Type = TSymbolicLink; } if( boost::filesystem::is_other( FileStatus ) ) { Type = TNotDefined; } if( boost::filesystem::is_directory( FileStatus ) ) { Type = TDirectory; DateChanged = boost::filesystem::last_write_time( Path ); } StateOfFile = FileOK; } else StateOfFile = IgnoreFile; }
time_t Dedupe::FileInfo::GetDateChanged | ( | ) | const |
Definition at line 112 of file fileinfo.cpp.
Referenced by Dedupe::Dataholding::Dataholding::AddFile(), Dedupe::Dataholding::Dataholding::AlreadyInDatabase(), Dedupe::Core::Kernel::FindFiledateDuplicates(), Dedupe::Core::Kernel::FindFiledateDuplicatesExtern(), and Dedupe::Dataholding::Dataholding::UpdateFile().
{
return DateChanged;
}
std::string Dedupe::FileInfo::GetErrorMessage | ( | ) | const |
Get the error message, that is stored, if FileStatus is set to IgnoreFile
Definition at line 166 of file fileinfo.cpp.
{
return FileSearchErrorMessage;
}
bool Dedupe::FileInfo::GetExisting | ( | ) | const |
unsigned long long Dedupe::FileInfo::GetHash | ( | ) | const |
Definition at line 140 of file fileinfo.cpp.
Referenced by Dedupe::Dataholding::Dataholding::AddFile(), Dedupe::Core::Kernel::FindHashDuplicates(), Dedupe::Core::Kernel::FindHashDuplicatesExtern(), and Dedupe::Dataholding::Dataholding::UpdateFile().
{
return Hash;
}
bool Dedupe::FileInfo::GetKeep | ( | ) | const [inline] |
Definition at line 146 of file fileinfo.h.
Referenced by Dedupe::Dataholding::Dataholding::AddFile(), and Dedupe::Dataholding::Dataholding::UpdateFile().
{ return Keep; }
Dedupe::FilePath Dedupe::FileInfo::GetPath | ( | ) | const |
Definition at line 98 of file fileinfo.cpp.
Referenced by Dedupe::Dataholding::Dataholding::AddFile(), Dedupe::Dataholding::Dataholding::AlreadyInDatabase(), Dedupe::Dataholding::Dataholding::DelFile(), Dedupe::Core::Kernel::FindFilenameDuplicates(), Dedupe::Core::Kernel::FindFilenameDuplicatesExtern(), Dedupe::Hash::Hash< T >::HashFileInfo(), Dedupe::GUI::QtMain::IsRecursive(), Dedupe::FileSearch::SearchFiles::Search(), and Dedupe::Dataholding::Dataholding::UpdateFile().
{
return Path;
}
unsigned long long Dedupe::FileInfo::GetSize | ( | ) | const |
Definition at line 105 of file fileinfo.cpp.
Referenced by Dedupe::Dataholding::Dataholding::AddFile(), Dedupe::Dataholding::Dataholding::AlreadyInDatabase(), Dedupe::Core::Kernel::FindFilesizeDuplicates(), Dedupe::Core::Kernel::FindFilesizeDuplicatesExtern(), and Dedupe::Dataholding::Dataholding::UpdateFile().
{
return Size;
}
Dedupe::FileInfo::FileStatus Dedupe::FileInfo::GetStatus | ( | ) | const |
Get FileStatus
Definition at line 154 of file fileinfo.cpp.
Referenced by Dedupe::FileSearch::SearchFiles::Search(), and Dedupe::FileSearch::SearchFiles::SearchRecursive().
{
return StateOfFile;
}
Dedupe::FileInfo::FileType Dedupe::FileInfo::GetType | ( | ) | const |
Definition at line 126 of file fileinfo.cpp.
Referenced by Dedupe::Dataholding::Dataholding::AddFile(), Dedupe::FileSearch::SearchFiles::Search(), and Dedupe::Dataholding::Dataholding::UpdateFile().
{
return Type;
}
bool Dedupe::FileInfo::operator< | ( | const FileInfo & | rhs | ) | const [inline] |
The operator is here to make std::sort() usable with FileInfo
Definition at line 156 of file fileinfo.h.
{ return Path < rhs.Path; }
void Dedupe::FileInfo::SetErrorMessage | ( | std::string const & | message | ) |
FileSearch and the FileInfo constructor can store some error messages here. Error Messages are only stored, if GetStatus has value "IgnoreFile"
Definition at line 160 of file fileinfo.cpp.
Referenced by FileInfo().
{ FileSearchErrorMessage = message; }
void Dedupe::FileInfo::SetHash | ( | unsigned long long const & | value | ) |
Sets the Hashvalue
Definition at line 133 of file fileinfo.cpp.
Referenced by Dedupe::Hash::Hash< T >::HashFileInfo().
{ Hash = value; }
void Dedupe::FileInfo::SetKeep | ( | bool | YesNo | ) | [inline] |
Give a bool to set the keep option. Keep is false by default
Definition at line 151 of file fileinfo.h.
{ Keep = YesNo; }
void Dedupe::FileInfo::SetStatus | ( | FileStatus | value | ) |