home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / util / glob / readme < prev   
Encoding:
Text File  |  1987-07-20  |  1.6 KB  |  41 lines

  1.   Here is a routine which does wildcard expansion for MS-DOS.
  2. It could be spiffed up by using the regex routines by Henry Spencer, but
  3. for now it expands DOS style wildcards (*,?):  (This is also found in
  4. the file example.c)
  5.  
  6.  
  7.  #include "glob.h"
  8.  main() {
  9.      char **names;
  10.      names = glob("*.c");
  11.      if (names)
  12.          printf("The first file which matches the wildcard: %s\n",names[0]);
  13.      else
  14.          printf("glob() error number %d\n",globerror);
  15.  }
  16.  
  17. It also handles the case of "/usr/pl*/bin/*.exe" where "/usr/pl*/bin" is unique.
  18. Unfortunately, the code does not handle "/*/*/*.c" type expansions.  This is
  19. an arbitrary limitation which is left to the student to implement. :-)))))
  20.  
  21. It also does not handle "C:/bin/*.exe"  - the drive spec fouls it up,
  22. MS-DOS seems to have problems with the find first/next functions in the
  23. root directory so "/*.c" may give you problems.
  24.  
  25. The shar which follows contains:
  26.     glob.c  glob.h        - the actual wildcard expansion routines
  27.     example.c        - a very simple example of its usage
  28.     chd.c            - a more complex example - implements chdir
  29.     chd.exe (uuencoded)    - compiled version of chd.c
  30.     glob.obj (uuencoded)    - linkable module containing glob()
  31.  
  32. Have fun, mail me if you have problems...
  33.  
  34. (PS I am not actively using MS-DOS for now, so this code has been sitting 
  35. "on the shelf" for a bit.  I saw a few comments in comp.sys.ibm.pc concerning
  36. Turbo C and its lack of wildcard support, so I figured I'd send this out.)
  37.  
  38.  John Plocher        UUCP: <backbone>!uwvax!geowhiz!uwspan!plocher
  39. ==============      Internet: plocher%uwspan.UUCP@uwvax.cs.Wisc.EDU
  40. FidoNet: 121/0          BITNET: uwvax!geowhiz!uwspan!plocher@psuvax1
  41.