#include <fileinfo.h>
Public Member Functions | |
FileInfo (Dedupe::FilePath PathToFile) | |
Dedupe::FilePath | GetPath () const |
unsigned long long | GetSize () const |
time_t | GetDateChanged () const |
bool | GetExisting () const |
Dedupe::FileInfo::FileType | GetType () const |
State::GeneralCodes | SetHash (unsigned long long const &value) |
unsigned long long | GetHash () const |
State::GeneralCodes | SetStatus (State::InfoFileSearch value) |
State::InfoFileSearch | GetStatus () const |
State::GeneralCodes | SetErrorMessage (std::string const &message) |
std::string | GetErrorMessage () const |
bool | operator< (const FileInfo &rhs) const |
This class represents a single file on the harddisk with all needed informations about the file. Check GetInfoFilesearch befor using. If Dedupe::State::IgnoreFile is returned, it is not save to trust the stored values, cause the constructor returns errors. Check GetErrorMessage() for more informations.
Definition at line 49 of file fileinfo.h.
Dedupe::FileInfo::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 ), FileSearchErrorMessage( "" ), Hash( 0 ) { //Creates a portable path from a native path PathToFile.string(); //Set path after creation of the portable path format!!! Path = PathToFile; /*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 ) { InfoFilesearch = Dedupe::State::IgnoreFile; SetErrorMessage( ec.message() ); } Existing = true; // Get the filestatus boost::filesystem::file_status FileStatus; FileStatus = boost::filesystem::symlink_status( Path, ec ); if( ec != 0 ) { InfoFilesearch = Dedupe::State::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 ); } } InfoFilesearch = Dedupe::State::FileSearchNotSet; }
time_t Dedupe::FileInfo::FileInfo::GetDateChanged | ( | ) | const |
Definition at line 89 of file fileinfo.cpp.
{
return DateChanged;
}
std::string Dedupe::FileInfo::FileInfo::GetErrorMessage | ( | ) | const |
Get the error message, that is stored if InfoFilesearch is set to Dedupe::State::IgnoreFile
Definition at line 154 of file fileinfo.cpp.
{
return FileSearchErrorMessage;
}
bool Dedupe::FileInfo::FileInfo::GetExisting | ( | ) | const |
unsigned long long Dedupe::FileInfo::FileInfo::GetHash | ( | ) | const |
Dedupe::FilePath Dedupe::FileInfo::FileInfo::GetPath | ( | ) | const |
Definition at line 75 of file fileinfo.cpp.
Referenced by Dedupe::FileSearch::SearchFiles::Search().
{
return Path;
}
unsigned long long Dedupe::FileInfo::FileInfo::GetSize | ( | ) | const |
Dedupe::State::InfoFileSearch Dedupe::FileInfo::FileInfo::GetStatus | ( | ) | const |
Get information Codes for module Filesearch
Definition at line 139 of file fileinfo.cpp.
Referenced by Dedupe::Core::Kernel::AppendFile(), Dedupe::FileSearch::SearchFiles::Search(), and Dedupe::FileSearch::SearchFiles::SearchRecursive().
{
return InfoFilesearch;
}
Dedupe::FileInfo::FileType Dedupe::FileInfo::FileInfo::GetType | ( | ) | const |
Definition at line 103 of file fileinfo.cpp.
Referenced by Dedupe::Core::Kernel::AppendFile(), and Dedupe::FileSearch::SearchFiles::Search().
{
return Type;
}
bool Dedupe::FileInfo::FileInfo::operator< | ( | const FileInfo & | rhs | ) | const [inline] |
The operator is here to make std::sort() usable with FileInfo
Definition at line 129 of file fileinfo.h.
{ return Path < rhs.Path; }
Dedupe::State::GeneralCodes Dedupe::FileInfo::FileInfo::SetErrorMessage | ( | std::string const & | message | ) |
FileSearch can store some error messages here, if InfoFilesearch is set to Dedupe::State::IgnoreFile
Definition at line 146 of file fileinfo.cpp.
Referenced by FileInfo(), and Dedupe::FileSearch::SearchFiles::Search().
{
FileSearchErrorMessage = message;
return Dedupe::State::Ok;
}
Dedupe::State::GeneralCodes Dedupe::FileInfo::FileInfo::SetHash | ( | unsigned long long const & | value | ) |
Sets the Hashvalue
Definition at line 111 of file fileinfo.cpp.
{
Hash = value;
return Dedupe::State::Ok;
}
Dedupe::State::GeneralCodes Dedupe::FileInfo::FileInfo::SetStatus | ( | State::InfoFileSearch | value | ) |
Set information Codes for module Filesearch
Definition at line 129 of file fileinfo.cpp.
Referenced by Dedupe::FileSearch::SearchFiles::Search().
{
InfoFilesearch = value;
return Dedupe::State::Ok;
}