home *** CD-ROM | disk | FTP | other *** search
- Path: senator-bedfellow.mit.edu!red-branch!rid
- From: rid@red-branch.MIT.EDU (Shawna Grimm)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: search engine
- Date: 8 Feb 1996 02:15:13 GMT
- Organization: Massachvsetts Institvte of Technology
- Distribution: na
- Message-ID: <4fbmbh$5h5@senator-bedfellow.MIT.EDU>
- References: <2205f9d8.0@amuc.mtroyal.ab.ca>
- NNTP-Posting-Host: red-branch.mit.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- MCollette (637684755@amuc.mtroyal.ab.ca) typed in the following on 02 Feb 96 16:16:24 MST:
- : Does abyone have any ideas as how to make a search engine that looks through
- : directories until it finds a file? My biggest problem is finding what sub
- : directories are in a directory, then changing to that sub directory. Please
- : help me with this, and keep in mind I only have Kick Start 1.3
- : Thanx
- : MCollette@amuc.mtroyal.ab.ca
-
- Using a recursive function to do this should make this extremely simple.
- Basically, you'll need a function that will read all the files in a
- directory, and then if the 'file' turns out to be a directory, call up it
- self with the directory name as paramater ... pseudocodeish, it should
- look something like this :
-
- void readdir(char *dirname)
- {
- opendir( dirname);
- while(!lastfile)
- {
- if(file == directory)
- readdir(file)
- else
- {
- check if file is what you are looking for ...
- }
- }
- }
-
- This will possibly require a large stack, but it will get the job done. I
- wrote a similar program under UN*X to scan a bunch of large disks, and it
- does the job beautifully... Unfortuantely, I don't have access to the
- sourcecode, so I can't give you those vital parts that you need. Hope the
- pseudo-code will be of assistance.
-
- * Lars M. Hansen
- * Duh. - H. Simpson
-
-
-