Go to the documentation of this file.00001
00009 #include "searchfiles.h"
00010 using namespace Dedupe::FileSearch;
00011
00012 SearchFiles::SearchFiles() : AllFiles( ), NotUsableFiles( ), Directories( ),
00013 DirectoryCounter( 0 ), FileCounter( 0 ) {}
00014
00015
00016
00017
00018 bool SearchFiles::Search( Dedupe::FileInfo &FileObject )
00019 {
00020 if( FileObject.GetStatus() == Dedupe::FileInfo::IgnoreFile ) return false;
00021 if( FileObject.GetType() != Dedupe::FileInfo::TDirectory ) return false;
00022
00023
00024 Dedupe::FileInfo *currentEntry;
00025
00026
00027 boost::system::error_code DirError;
00028
00029
00030
00031
00032 for( boost::filesystem::directory_iterator
00033 entry( FileObject.GetPath(), DirError );
00034 entry != boost::filesystem::directory_iterator(); entry++ )
00035 {
00036
00037
00038
00039
00040 currentEntry = new Dedupe::FileInfo( *entry );
00041
00042
00043 if( currentEntry->GetType() == Dedupe::FileInfo::TFile )
00044 {
00045 AllFiles.push_back( *currentEntry );
00046 FileCounter++;
00047 }
00048 else if( currentEntry->GetType() == Dedupe::FileInfo::TDirectory )
00049 {
00050 Directories.push_back( *currentEntry );
00051 DirectoryCounter++;
00052 }
00053 else
00054 {
00055 NotUsableFiles.push_back( *currentEntry );
00056 }
00057 delete( currentEntry );
00058
00059 }
00060 return true;
00061 }
00062
00063
00064
00065 bool SearchFiles::SearchRecursive( Dedupe::FileInfo &FileObject )
00066 {
00067 if( FileObject.GetStatus() == Dedupe::FileInfo::IgnoreFile )
00068 {
00069 return false;
00070 }
00071
00072 if( !Search( FileObject ) ) return false;
00073
00074 Dedupe::FileInfo *Info;
00075 do
00076 {
00077 if( Directories.size() == 0 ) continue;
00078 Info = new Dedupe::FileInfo( Directories.back() );
00079 Directories.pop_back();
00080 Search( *Info );
00081
00082 if( Directories.size() == 0 ) break;
00083
00084 }while( Directories.size() != 0 );
00085
00086 return true;
00087 }