c++ - search client's computer for specific files -


what fastest way of searching clients's computer (and other mounted drives) images. clients have desktop app installed in python can add c++ code if faster...

if platform win32, c++ can use winapi functions

findfirstfile

findfirstfileex

and then

findnextfile

as filename can give wildcards known image formats such jpg, jpeg, png, bmp etc.

if want speed can run functions on different threads synchronize results.

edit:

for platform independent solution can use boost::filesystem class or qt's qdir

sample code searching files recursively boost::filesystem

std::string target_path( "c:\\" ); boost::regex my_filter( "*\.bmp" ); std::vector< std::string > all_matching_files; ( boost::filesystem::recursive_directory_iterator end, dir(target_path);      dir != end; ++dir )  {     // skip if not file     if( !boost::filesystem::is_regular_file( i->status() ) )          continue;     boost::smatch what;      // skip if no match     if( !boost::regex_match( i->leaf(), what, my_filter ) ) continue;      // file matches, store     all_matching_files.push_back( i->leaf() );                                  } 

for better implenetation offer read boost::filesystem documentation

for qdir example

filesstack = new qstack<qstring>();  qdir selecteddir("c:\\"); selecteddir.setfilter(qdir::files | qdir::dirs | qdir::nodot | qdir::nodotdot); qstringlist qsl; qsl.append("*.bmp"); selecteddir.setnamefilters(qsl); findfilesrecursively(selecteddir);   void findfilesrecursively(qdir rootdir)  {     qdiriterator it(rootdir, qdiriterator::subdirectories);     while(it.hasnext())      {         filesstack->push(it.next());     } } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -