File searching

Started by
4 comments, last by doctorsixstring 21 years, 11 months ago
Is there any particular function that will search an entire drive for a particular file? I have been studying FindFirstFile() and FindNextFile(), but it seems like it would be quite laborious to use those functions to search the entire hard drive. Is there another, simple function to do this? I'm using Visual C++ 6.0 w/ the Win32 API. Thanks, Mike [edited by - doctorsixstring on April 29, 2002 4:56:25 PM]
Advertisement
No.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!
Why would it be laborious? Can''t you just use that function in a for loop and compare if the filename to what you''ve found?

I haven''t used that function before though.
recursion is the simplfication you are missing. you search through all the files (directories are files too) in the root directory first. then each time you hit a directory, you call your search function again with the new path (ie ./newdirectory). you continually do this and eventually you will go through all the files.
How do you do to search recursively? Do you have a link for an example showing this way of searching a file in a HD?
Thanks in advance.
Pseudo-code:
function findFile(string name, string directoryName){    enumeration e = getDirectoryContents(directoryName);    for(item i in e)    {        if(i.name is name)        {            print("found it in " + directory);            break;        }        if(i.type is directory)        {            findFile(name, directoryName + i.name);        }    }} 

char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/

This topic is closed to new replies.

Advertisement