#include <searchfiles.h>
Public Member Functions | |
| virtual Dedupe::FileStream const & | GetFiles () const |
| Dedupe::FileStream const & | GetNotUsableFiles () const |
| unsigned long const & | GetDirectoryCounter () const |
| unsigned long const & | GetFileCounter () const |
| bool | Search (Dedupe::FileInfo &FileObject) |
| bool | SearchRecursive (Dedupe::FileInfo &FileObject) |
Protected Attributes | |
| Dedupe::FileStream | AllFiles |
| Dedupe::FileStream | NotUsableFiles |
| Dedupe::FileStream | Directories |
| unsigned long | DirectoryCounter |
| unsigned long | FileCounter |
SearchBase defines a class for all searching operations
Definition at line 24 of file searchfiles.h.
| unsigned long const& Dedupe::FileSearch::SearchFiles::GetDirectoryCounter | ( | ) | const [inline] |
Get the number of all founded directorys ( Not usable ones will not be counted! )
Definition at line 57 of file searchfiles.h.
{
return DirectoryCounter;
}
| unsigned long const& Dedupe::FileSearch::SearchFiles::GetFileCounter | ( | ) | const [inline] |
Get the number of all founded files ( Not usable ones will not be counted! )
Definition at line 67 of file searchfiles.h.
{
return FileCounter;
}
| virtual Dedupe::FileStream const& Dedupe::FileSearch::SearchFiles::GetFiles | ( | ) | const [inline, virtual] |
This function is used to get the result of the Search
Definition at line 37 of file searchfiles.h.
{
return AllFiles;
}
| Dedupe::FileStream const& Dedupe::FileSearch::SearchFiles::GetNotUsableFiles | ( | ) | const [inline] |
All files that could not be open or used in the module staying here
Definition at line 47 of file searchfiles.h.
{
return NotUsableFiles;
}
| bool SearchFiles::Search | ( | Dedupe::FileInfo & | FileObject | ) |
Searchs for all files behind the given directory. The given FileInfo must be a directory. Get the founded files with a call of GetFiles()
Definition at line 18 of file searchfiles.cpp.
References Dedupe::FileInfo::GetPath(), Dedupe::FileInfo::GetStatus(), and Dedupe::FileInfo::GetType().
Referenced by SearchRecursive().
{
if( FileObject.GetStatus() == Dedupe::FileInfo::IgnoreFile ) return false;
if( FileObject.GetType() != Dedupe::FileInfo::TDirectory ) return false;
Dedupe::FileInfo *currentEntry;
//Set up a boost error_code to use a iterator without exceptions
boost::system::error_code DirError;
//TODO manage DirErrors, or instead make sure FileInfo filters before
//run actual directory
for( boost::filesystem::directory_iterator
entry( FileObject.GetPath(), DirError );
entry != boost::filesystem::directory_iterator(); entry++ )
{
currentEntry = new Dedupe::FileInfo( *entry );
//Sort all entrys to right vector
if( currentEntry->GetType() == Dedupe::FileInfo::TFile )
{
AllFiles.push_back( *currentEntry );
FileCounter++;
}
else if( currentEntry->GetType() == Dedupe::FileInfo::TDirectory )
{
Directories.push_back( *currentEntry );
DirectoryCounter++;
}
else
{
NotUsableFiles.push_back( *currentEntry );
}
delete( currentEntry );
}
return true;
}
| bool SearchFiles::SearchRecursive | ( | Dedupe::FileInfo & | FileObject | ) |
Searchs for all files and directories behind the given directory. The given FileInfo must be a directory. Get the founded files with a call of GetFiles()
Definition at line 65 of file searchfiles.cpp.
References Dedupe::FileInfo::GetStatus(), and Search().
{
if( FileObject.GetStatus() == Dedupe::FileInfo::IgnoreFile )
{
return false;
}
if( !Search( FileObject ) ) return false;
Dedupe::FileInfo *Info;
do
{
if( Directories.size() == 0 ) continue;
Info = new Dedupe::FileInfo( Directories.back() );
Directories.pop_back();
Search( *Info );
if( Directories.size() == 0 ) break;
}while( Directories.size() != 0 );
return true;
}
1.7.1