↑ Software ↑


drs_util - Directory Scanning Utilities

The functions in the DRS_UTIL package are used to scan the names of the files in a directory. Wildcards can be used to filter out unwanted files. The following example prints out the names of the .c files in a directory:

    #include  <stdio.h>			-- Standard I/O definitions.
    #include  "drs_util.h"		-- Directory scanning utilities.
    int  main (int argc, char *argv[])
        char  *fileName ;
        DirectoryScan  scan ;

        drsCreate ("*.c", &scan) ;
        fileName = drsFirst (scan) ;
        while (fileName != NULL) {
            printf ("C File: %s\n", fileName) ;
            fileName = drsNext (scan) ;
        drsDestroy (scan) ;
Alternatively, you can call drsGet() to get the I-th name in the directory:

    for (i = 0 ;  i < drsCount (scan) ;  i++)
        printf ("C File: %s\n", drsGet (scan, i)) ;


This package is derived from and supersedes my fsearch() routine. Farewell, VMS!

Public Procedures

drsCount() - returns the number of files in a directory scan.
drsCreate() - creates a directory scan.
drsDestroy() - destroys a directory scan.
drsFirst() - gets the first entry in the directory.
drsGet() - gets the I-th entry in the directory.
drsNext() - gets the next entry in the directory.

Source Files


(See libgpl for the complete source, including support routines and build files.)

Alex Measday  /  E-mail