2020-09-21 16:10:29 +00:00
|
|
|
/*********************************
|
|
|
|
* DISKDIR - Read Disk Directory *
|
|
|
|
*********************************/
|
|
|
|
|
|
|
|
//Specify System Header using -H option
|
|
|
|
#include <screen.h02>
|
|
|
|
#include <stddef.h02>
|
|
|
|
#include <stdlib.h02>
|
|
|
|
#include <intlib.h02>
|
|
|
|
#include <stdio.h02>
|
|
|
|
#include <stdiox.h02>
|
|
|
|
#include <memory.h02>
|
|
|
|
#include <string.h02>
|
|
|
|
#include <fileio.h02>
|
|
|
|
#include <dirent.h02>
|
2020-10-14 14:59:25 +00:00
|
|
|
#include <time.h02>
|
2020-09-21 16:10:29 +00:00
|
|
|
|
|
|
|
struct dirent entry;
|
|
|
|
struct dirhdr header;
|
2020-10-14 14:59:25 +00:00
|
|
|
struct tm time;
|
2020-09-21 16:10:29 +00:00
|
|
|
|
2020-10-14 14:59:25 +00:00
|
|
|
const char drv = 0; //Drive ID (Current Drive)
|
|
|
|
const char dir = ""; //Directory Name (Current Directory)
|
|
|
|
char dp; //Directory File Pointer
|
|
|
|
char err; //Error Code
|
|
|
|
char c; //Character read from Struct
|
|
|
|
char i; //Loop Index Variable
|
|
|
|
char n; //Number of Characters Read
|
|
|
|
char m[128], s[128], t[128]; //String Buffers
|
|
|
|
int dircnt,filcnt; //Directories and File Count
|
2020-09-21 16:10:29 +00:00
|
|
|
char aa,ff,xx,yy,zz; //Function Arguments
|
|
|
|
|
2020-10-14 14:59:25 +00:00
|
|
|
/* Print Entry Time Stamp */
|
|
|
|
void prtts() {setdst(t); asctm(#FLONG|#FAMPM, entry.time); puts(t);}
|
|
|
|
|
|
|
|
/* Print Directory Entry */
|
|
|
|
void prtent() {
|
|
|
|
if (entry.attr.subdir) dircnt++; else filcnt++;
|
|
|
|
if (@entry.time > 1) {prtts(); puts(" ");}
|
|
|
|
for (i=0; i<@entry.attr; i++) {if (entry.attr[i]) putc(attrd[i]); else putspc();}
|
|
|
|
setdst(entry.size); printf(" %j "); putln(entry.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print Directory Summary */
|
|
|
|
void prtsum() {
|
|
|
|
setdst(filcnt); printf(" %j FILES(S)%n");
|
|
|
|
setdst(dircnt); printf(" %j DIR(S)%n");
|
|
|
|
}
|
|
|
|
|
2020-09-21 16:10:29 +00:00
|
|
|
main:
|
2020-10-14 14:59:25 +00:00
|
|
|
filcnt = &0; dircnt = &0;
|
2020-09-21 16:10:29 +00:00
|
|
|
setdst(dir); printf("OPENING DIRECTORY '%s'%n");
|
2020-10-14 14:59:25 +00:00
|
|
|
dp, err = opndir(drv, dir); if (err) goto error;
|
2020-09-21 16:10:29 +00:00
|
|
|
printf(dp, "CHANNEL=%d%n");
|
|
|
|
|
|
|
|
putln("READING HEADER");
|
2020-10-14 14:59:25 +00:00
|
|
|
n, err = rdhdr(dp, header); if (err) goto error;
|
|
|
|
if (n) putln(header.name); else putln("NO HEADER");
|
2020-09-21 16:10:29 +00:00
|
|
|
|
|
|
|
putln("READING ENTRIES");
|
|
|
|
do {
|
|
|
|
n, err = rddir(dp, entry);
|
2020-10-14 14:59:25 +00:00
|
|
|
if (n) prtent();
|
2020-09-21 16:10:29 +00:00
|
|
|
} while (n);
|
|
|
|
if (err) goto error;
|
2020-10-14 14:59:25 +00:00
|
|
|
prtsum();
|
|
|
|
//putln("END OF DIRECTORY");
|
2020-09-21 16:10:29 +00:00
|
|
|
|
2020-10-14 14:59:25 +00:00
|
|
|
err = clsdir(dp); if (err) goto err;
|
2020-09-21 16:10:29 +00:00
|
|
|
goto exit;
|
|
|
|
|
|
|
|
error:
|
|
|
|
printf(err, "ERROR %d%n");
|
|
|
|
goto exit;
|