GEMDOS File System Functions
)
Fsetdta (olddta); /* then restore DTA */
/* if you're running this fro m the Desktop, you nay want to
add a pause to give the user a chance to read the output */
Cconws("\n\n\rPress any key to end");
Cconin();
) /* end of main */
print entry() / * format output for directory listings */
{
char temp[2 0 ];
Cconws(dta.fname); /* print file name * /
Cconws(blank+strlen(dta.fname)); /* pad to 12 spaces */
if(dta.attr==OxlO) /* if this is a directory */
{
Cconws("<DIR>\r\n"); /* don't print size or date */
)
else
sprintf(temp,"%71d",dta.fsize); / * else print file size * /
Cconws(temp);
Cconws(" bytes ");
sprintf(temp,"%02d/%02d/%d", /* print file date */
dta.fdate&OxlF, (dta.fdate &0xlE0)»5,
(dta. fdate»9)+1980) ;
Cconws(temp);
Cconws(" ");
sprintf(temp,n%02d:%02d:%02 d", /* print file time * /
(dta.ftime»ll)60xlF, (dta.ftime &0x7E0)»5,
(dta.ftime&OxlF)*2);
Cconws(temp);
Cconws("\r\n");
)
) /* end of print_entry() */
****************** end of GDIR.C ***********/
After compiling this program, you should rename it
GDIR.TTP to indicate that it may take parameters. To obtain
a specific directory listing, enter the directory name as the
parameter, including wildcard characters, like C:\PRO-
GRAMS\*.PRG. You may also run this program from within
the GPEXEC.TOS program described in Chapter 5. Once
GPEXEC prompts you for a command, enter it in the format:
GDIR.TTP A:Y\*
Directory Listings and Free Space Functions
One of the most common disk operations is obtaining a list
ing of the directory contents. Since a disk may have
hundreds of files and subdirectories, it might be difficult set
125