Find Directory Files Easily and Execute a Function for Each of Them

The CScanPath is designed for all developers who want to implement a scanning function for directory/subdirectory files and interact with each of them.

How It Works

When starting the scanning job through the CScanPath class, a separate thread search is created for all files in the directory tree structure. It executes the specified function for each of them. The class also gives you the possibility to get the total directory files' numbers, and the total directory files' sizes.

How to Use It

If you want to know the total directory files sizes or the total directory files numbers, you can use the following method:

  • DWORD GetDirFilesNumbers( char * path )
  • double GetDirFilesSizes( char * path )

where path is the directory to search for.

Now, to scan a directory and manipulate each file found, proceed like this:

  1. Declare a static function.
  2. static void MyFunction( char * file );
  3. Make the function to manipulate files found.
  4. void MyFunction( char * file )
    {
       printf("-> %s\n", file);
    }
    
  5. Call the RunScan method.
  6. CScanPath ScanPath;
    ScanPath.RunScan( "c:\\windows", MyFunction );
    

    If you want to stop scanning for any reason, just do this:

    ScanPath.StopScan();

That's ALL!

Sample Code for Console Program

#include <windows.h>
#include "<stdio.h>"
#include "ScanPath.h"

void MyFunction( char * file )
{
   printf("-> %s\n", file );
}

void main( int argc, char **argv )
{

   if( argc < 2 )
   {
      printf("Usage : %s <path to scan>\n", argv[0] );
      ExitProcess(0);
   }

   if( !SetCurrentDirectory( argv[1] ) )
   {
      printf("Error : %s in not a valid directory !\n", argv[1]);
      ExitProcess(0);
   }

   CScanPath Scan;

   // the third argument means that the function doesn't return
   // until the scan ends
   // this is FALSE by default.
   Scan.RunScan( argv[1], MyFunction, TRUE );
}


About the Author

Aurelien BOUDOUX

Visit my web site on http://www.techandfeel.com !

Downloads

Comments

  • порно лижут анус бесплатно

    Posted by Amalurond on 03/27/2013 09:38pm

    [u]ебля в два члена[/u] Она вдруг высвободилась, переместилась выше - так, чтоб грудь заколыхалась над Его лицом, а лобок влажно чмокнул головку члена.

    Reply
  • Naked Teens Fucking, Sexy Teens Having Sex, Barely Legal Teens! - black teens fucking only white guys

    Posted by Kilopaterai on 01/16/2013 04:46pm

    12 Aug 2011 ANDROID GIRLS WALLPAPER 2. My Body is Sex. Posted by wallpaper girl at 00:15 0 16 Teen Dv 17 Only Teens Sex 18 Awesome Teen Pussy Vids 19 Teens Sexy Movies 20 19 Yo Porn, 61 57 44 42 41 36 31 30 25 24 Free Porn Movies - Tube Galore . com. The World's #1 Most Visited Video Chat Web sex cams:Webcam online strip girls enjoy porn adult entertainment. Cam private performance is your partner. Can't touch him website one is an exception . porn teen thailand video porn-teen-thailand-video mobile porn PORN TEEN THAILAND free xxx porn at webxczech quality movie galleries updated daily! EMO Gay Porn · Gay Teen Movies · Male Movies · Gay boy movies gay teen homemade movies | home made totaly free gay video and movies | young harry potter magazines · xxx girls XXX girls · art, design · automotive · business, finance · computer, internet · fashion, lifestyle · hobbies, leisure time 12 year virgin girls sex school tube Videos,12 year virgin girls sex school tube Porn,12 year virgin girls sex school tube Sex Videos,12 year virgin girls Sleeping bitch fucked, Asleep teen assault! Black Porn Movies. Hottest Black Girls. hot black girls blackcholly.com - blackcholly.com Adult Emoticons The best porn videos from Stoney Curtis's Lethal Hardcore studio are available CFNM Sex parties, free cfnm pictures, cfnm porn movies. That girls didn't put on her panties today! Another girl is having sex with a black guy in Bunny movie porn teen, diana post xxx, disco sex party, sexy kathy smith. Virgin Sex for Girls features more than 40 true stories from teens and adults about their first experiences–the physical, emotional, and social consequences Watch free porn & movie trailers: anal videos, big cock movies, Angelina Jolie 100% Free Teen Sex Pictures and Free Teen Sex Movies! Huge Free Sex Free Porn Archive. MilkMans Book. The 0riginal! Always quality Links.

    Reply
  • Why my Console Program can not be compiling?

    Posted by caixing_200 on 01/12/2008 10:07pm

    I am a beginner of C++. I want to use CScanpath class. I use it in a C++ Console Program according to the author's method as possible as I can. But the program can not be compiling. When I compile the program, It produces the error information error C2065b: undeclared identifier .What should I do? Please explain it step by step and offer the source code. Thank you! (My source code with some wrong is in my yahoo Email.username:c.question,password:jg123456) Development environment: Microsoft Windows 2000 Service pack 4 and Microsoft Visual C++.net 2003.

    Reply
  • How to handle quit while processing?

    Posted by Large on 06/20/2006 12:13pm

    Hi the class look great!
    
    I wonder how you would handle if the program was closed while thread is running. Is this the best way?
    
    CScanPath::~CScanPath()
    {
    	this->StopScan();	
    	WaitForSingleObject( hThread, INFINITE );
    }
    
    Please give me suggestions if you have any :)

    • Source code updated to 1.1

      Posted by aurelien on 06/21/2006 01:52pm

      Hi Lars, and thanks for your comment. I have make a little update to the Class for properly kill the working thread when object is deleted, and prevent multiple RunScan method launch. I hope it will be online soon. Thank you very much for your remark, and sorry for my english ;)

      Reply
    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • With 81% of employees using their phones at work, companies have stopped asking: "Is corporate data leaking from personal devices?" and started asking: "How do we effectively prevent corporate data from leaking from personal devices?" The answer has not been simple. ZixOne raises the bar on BYOD security by not allowing email data to reside on the device. In addition, Zix allows employees to maintain complete control of their personal device, therefore satisfying privacy demands of valued employees and the …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds