Code: Alles auswählen
#include <boost/filesystem.hpp>
#include <iostream>
class FileInfo
{
public:
/**
*Use the filepath to construct this class
*constructor with Dedupe::FilePath (typedef of boost::filesystem::path)
*/
FileInfo( Dedupe::FilePath PathToFile );
FileInfo( Dedupe::FilePath PathToFile,
unsigned long long size,
time_t ChangeDate,
Dedupe::FileInfo::FileType Type );
FileInfo( Dedupe::FilePath PathToFile,
unsigned long long size,
time_t ChangeDate,
Dedupe::FileInfo::FileType Type,
unsigned long long HashValue );
/*****************************************************************************/
/**
*@return path to file
*/
Dedupe::FilePath GetPath() const;
/**
*@return size of the file in bytes
*/
unsigned long long GetSize() const;
/**
*@return the date of the last file change
*/
time_t GetDateChanged() const;
/**
*@return true, if file is existing
*/
bool GetExisting() const;
/**
*@return one constant from FileType
*/
Dedupe::FileInfo::FileType GetType() const;
/*****************************************************************************/
/**
*Sets the Hashvalue
*/
void SetHash( unsigned long long const &value );
/**
*@return the Hash Value
*/
unsigned long long GetHash() const;
/*****************************************************************************/
/**
*Set FileStatus
*/
void SetStatus( FileStatus value );
/**Get FileStatus
*@return one constant from FileStatus
*/
FileStatus GetStatus() const;
/**
*FileSearch and the FileInfo constructor can store some error messages
*here. Error Messages are only stored, if GetStatus has value "IgnoreFile"
*/
void SetErrorMessage( std::string const &message );
/**
*Get the error message, that is stored, if FileStatus is set to IgnoreFile
*/
std::string GetErrorMessage() const;
/*****************************************************************************/
/**
*The operator is here to make std::sort() usable with FileInfo
*/
bool operator < (const FileInfo & rhs ) const { return Path < rhs.Path; }
friend bool operator== ( const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs);
friend bool operator!= ( const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs);
friend std::ostream& operator<<( std::ostream& os, const Dedupe::FileInfo& Info );
/*****************************************************************************/
private:
Dedupe::FilePath Path;
unsigned long long Size;
time_t DateChanged;
bool Existing;
Dedupe::FileInfo::FileType Type;
unsigned long long Hash;
FileStatus StateOfFile;
std::string FileSearchErrorMessage;
};
/**
*FileStream is a vector of Dedupe::Fileinfo
*/
typedef std::vector<Dedupe::FileInfo> FileStream;
}
inline bool operator== ( const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs)
{
return( rhs.Path == lhs.Path )
&& ( rhs.GetDateChanged() == lhs.GetDateChanged() )
&& ( rhs.GetExisting() == lhs.GetExisting() )
&& ( rhs.GetType() == lhs.GetType() )
&& ( rhs.GetHash() == lhs.GetHash() );
}
inline bool operator!= ( const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs)
{
return !( rhs == lhs );
}
inline std::ostream& operator<< ( std::ostream& os, const Dedupe::FileInfo& Info )
{
os << Info.GetPath() << ":" << Info.GetDateChanged() << ":" << Info.GetExisting()
<< ":" << Info.GetType() << ":" << Info.GetHash();
return os;
}
#endif
Code: Alles auswählen
inline bool operator== ( const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs)
{
return( rhs.Path == lhs.Path )
&& ( rhs.GetDateChanged() == lhs.GetDateChanged() )
&& ( rhs.GetExisting() == lhs.GetExisting() )
&& ( rhs.GetType() == lhs.GetType() )
&& ( rhs.GetHash() == lhs.GetHash() );
}
Zweites Problem. Dieser Operator
Code: Alles auswählen
inline bool operator!= ( const Dedupe::FileInfo rhs, const Dedupe::FileInfo lhs)
{
return !( rhs == lhs );
}
Als ich gegoogled habe, bin ich darauf gestoßen, dass der Kompiler hier vergeblich versucht implizit auf einen Typ zu casten, es ihm aber nicht gelingt. Jetzt bin ich aber völlig verwirrt, ich vergleiche doch einfach zwei FileInfo Objekte, oder bin ich blind?
Danke für eure Hilfe