home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 3185 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

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