home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name drsnext -- Find the next matching file
- *
- * Synopsis ercode = drsnext(pfile);
- *
- * int ercode DOS function return error code
- * FSPEC *pfile File information on matching file
- *
- * Description DRSNEXT is used in conjunction with DRSFIRST to return
- * information on all files matching requirements set when
- * DRSFIRST is called. DRSFIRST must be called before
- * DRSNEXT is first invoked, but then subsequent calls to
- * DRSNEXT return information on remaining matching files.
- * See DRSFIRST for a detailed description of the
- * information returned.
- *
- * If the value of the function is 0 (i.e., no error), then
- * a file was found and DRSNEXT can be used again to find
- * further files matching the name and attribute which were
- * specified when DRSFIRST was called. If the value of the
- * function is 18, then no matching files were found, and
- * DRSNEXT will not find any more matching files.
- *
- * Returns ercode DOS function error code
- * *pfile File information for the matching file
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <bdirect.h>
- #include <bfile.h>
-
- int drsnext(pfile)
- FSPEC *pfile;
- {
- ADS dta_ads,buf_ads,file_ads;
- int ercode;
- DOSREG dos_reg;
-
- flretdta(&dta_ads); /* Return DTA location, and set */
- utabsptr(b_drbuffer,&buf_ads); /* the new DTA location. */
- flsetdta(&buf_ads);
-
- dos_reg.ax = 0x4f00;
- ercode = dos(&dos_reg);
-
- if (ercode == 0) /* Found a match, now get info */
- { /* and move into the FSPEC */
- /* variable. */
- utabsptr((char *) pfile,&file_ads);
- buf_ads.r += 20; /* File info is at offset 20 */
- utslmove(&buf_ads,&file_ads,23);
- pfile->fattr = uthibyte(pfile->fattr); /* Move attribute value */
- } /* into the proper byte. */
-
- flsetdta(&dta_ads); /* Restore the DTA location */
-
- return(ercode);
- }