Go to the documentation of this file.00001
00008 #include "fileinfo.h"
00009
00010 Dedupe::FileInfo::FileInfo( Dedupe::FilePath PathToFile ):
00011 Path(""), Size( 0 ), DateChanged( 0 ), Existing( false ),
00012 Type( TNotAvailable ), Hash( 0 ), Keep( false ),
00013 StateOfFile( FileStatusNotSet ), FileSearchErrorMessage( "" )
00014 {
00015
00016 PathToFile.string();
00017
00018
00019 Path = boost::filesystem::absolute(
00020 PathToFile, boost::filesystem::current_path());
00021
00022
00023
00024 boost::system::error_code ec;
00025
00026 if( boost::filesystem::exists( Path, ec ) )
00027 {
00028 if( ec != 0 )
00029 {
00030 StateOfFile = IgnoreFile;
00031 SetErrorMessage( ec.message() );
00032 }
00033 Existing = true;
00034
00035
00036 boost::filesystem::file_status FileStatus;
00037
00038 FileStatus = boost::filesystem::symlink_status( Path, ec );
00039 if( ec != 0 )
00040 {
00041 StateOfFile = IgnoreFile;
00042 SetErrorMessage( ec.message() );
00043 }
00044
00045 if( boost::filesystem::is_regular_file( FileStatus ) )
00046 {
00047
00048 Size = boost::filesystem::file_size( Path );
00049
00050 DateChanged = boost::filesystem::last_write_time( Path );
00051 Type = TFile;
00052 }
00053
00054 if( boost::filesystem::is_symlink( FileStatus ) )
00055 {
00056 Type = TSymbolicLink;
00057 }
00058
00059 if( boost::filesystem::is_other( FileStatus ) )
00060 {
00061 Type = TNotDefined;
00062 }
00063
00064 if( boost::filesystem::is_directory( FileStatus ) )
00065 {
00066 Type = TDirectory;
00067 DateChanged = boost::filesystem::last_write_time( Path );
00068 }
00069 StateOfFile = FileOK;
00070 }
00071 else StateOfFile = IgnoreFile;
00072 }
00073
00074 Dedupe::FileInfo::FileInfo( Dedupe::FilePath PathToFile,
00075 unsigned long long size,
00076 time_t ChangeDate,
00077 Dedupe::FileInfo::FileType Type,
00078 bool keep )
00079
00080 : Path( PathToFile ), Size( size ), DateChanged( ChangeDate ),
00081 Existing( true ), Type( Type ), Hash( 0 ), Keep( keep ),
00082 StateOfFile( Dedupe::FileInfo::UncheckedFile ), FileSearchErrorMessage( "") {}
00083
00084
00085 Dedupe::FileInfo::FileInfo( Dedupe::FilePath PathToFile,
00086 unsigned long long size,
00087 time_t ChangeDate,
00088 Dedupe::FileInfo::FileType Type,
00089 bool keep,
00090 unsigned long long HashValue )
00091
00092 : Path( PathToFile ), Size( size ), DateChanged( ChangeDate ),
00093 Existing( true ), Type( Type ), Hash( HashValue ), Keep( keep ),
00094 StateOfFile( Dedupe::FileInfo::UncheckedFile ), FileSearchErrorMessage( "") {}
00095
00096
00097
00098 Dedupe::FilePath Dedupe::FileInfo::GetPath() const
00099 {
00100 return Path;
00101 }
00102
00103
00104
00105 unsigned long long Dedupe::FileInfo::GetSize() const
00106 {
00107 return Size;
00108 }
00109
00110
00111
00112 time_t Dedupe::FileInfo::GetDateChanged() const
00113 {
00114 return DateChanged;
00115 }
00116
00117
00118
00119 bool Dedupe::FileInfo::GetExisting() const
00120 {
00121 return Existing;
00122 }
00123
00124
00125
00126 Dedupe::FileInfo::FileType Dedupe::FileInfo::GetType() const
00127 {
00128 return Type;
00129 }
00130
00131
00132
00133 void Dedupe::FileInfo::SetHash( unsigned long long const &value )
00134 {
00135 Hash = value;
00136 }
00137
00138
00139
00140 unsigned long long Dedupe::FileInfo::GetHash() const
00141 {
00142 return Hash;
00143 }
00144
00145
00146
00147 void Dedupe::FileInfo::SetStatus( FileStatus value )
00148 {
00149 StateOfFile = value;
00150 }
00151
00152
00153
00154 Dedupe::FileInfo::FileStatus Dedupe::FileInfo::GetStatus() const
00155 {
00156 return StateOfFile;
00157 }
00158
00159
00160 void Dedupe::FileInfo::SetErrorMessage( std::string const &message )
00161 {
00162 FileSearchErrorMessage = message;
00163 }
00164
00165
00166 std::string Dedupe::FileInfo::GetErrorMessage() const
00167 {
00168 return FileSearchErrorMessage;
00169 }
00170