Public Member Functions

Dedupe::FileInfo::FileInfo Class Reference

#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

Detailed Description

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.


Constructor & Destructor Documentation

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;
}


Member Function Documentation

time_t Dedupe::FileInfo::FileInfo::GetDateChanged (  )  const
Returns:
the date of the last file change

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
Returns:
true, if file is existing

Definition at line 96 of file fileinfo.cpp.

{
  return Existing;
}

unsigned long long Dedupe::FileInfo::FileInfo::GetHash (  )  const
Returns:
the Hash Value

Definition at line 120 of file fileinfo.cpp.

{
  return Hash;
}

Dedupe::FilePath Dedupe::FileInfo::FileInfo::GetPath (  )  const
Returns:
path to file

Definition at line 75 of file fileinfo.cpp.

Referenced by Dedupe::FileSearch::SearchFiles::Search().

{
  return Path;
}

unsigned long long Dedupe::FileInfo::FileInfo::GetSize (  )  const
Returns:
size of the file in bytes

Definition at line 82 of file fileinfo.cpp.

{
  return Size;
}

Dedupe::State::InfoFileSearch Dedupe::FileInfo::FileInfo::GetStatus (  )  const

Get information Codes for module Filesearch

Returns:
information Codes

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
Returns:
one of Type from Dedupe::FileInfo::FileType

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

Returns:
Dedupe::State::ok

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

Returns:
Dedupe::State::ok

Definition at line 129 of file fileinfo.cpp.

Referenced by Dedupe::FileSearch::SearchFiles::Search().

{
  InfoFilesearch = value;

  return Dedupe::State::Ok;
}


The documentation for this class was generated from the following files: