Category : C Source Code
Archive   : JAZ_CLIB.ZIP
Filename : JZDIRLST.DMO

 
Output of file : JZDIRLST.DMO contained in archive : JAZ_CLIB.ZIP
/*
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³dirlst.c ³
³Demo of directory routines ³
³ ³
³Usage: dirlst *.c ³
³ ³
³ ³
³ (C) JazSoft Software by Jack A. Zucker (301) 794-5950 ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
*/

#include "jzdirect.h"
#include "jaz.h"

struct dir {
unsigned char attr; /* file attribute */
struct tdirtime time; /* creation time */
struct tdirdate date; /* creation date */
long size; /* file size */
char name[13]; /* file name */
};

struct tree {
struct dir wdir;
struct tree *pleft,*prite;
};

#define TREE struct tree

int wcount = 0;

main(argc,argv)
int argc;
char **argv;
{
char wname[50];
TREE *whead,*insert();
int werr;
TDIR wlist;
TFAT wfat;

if (argc != 2) strcpy(wname,"*.*");
else strcpy(wname,argv[1]);

whead = 0;
werr = jzfndfst(wname,32,&wlist);
if (! werr) {
do {
whead = insert(whead,wlist);
werr = jzfndnxt(&wlist);
} while ( ! werr);
treeprint(whead);
jzdskfre(&wfat,0);
printf("\n%9d File(s) %9ld bytes free",wcount,wfat.free);
printf("\n%9s %9ld bytes used","",wfat.used);
printf("\n%9s %9ld total space","",wfat.total);
}
else printf("\nNo match for %s",argv[1]);
}



TREE *insert(fptr,fdir)
TREE *fptr;
TDIR fdir;
{
if (fptr == 0) { /* install new wdir name */
fptr = (TREE *) malloc(sizeof(TREE));
strcpy(fptr->wdir.name,fdir.name);
fptr->wdir.attr = fdir.attr;
fptr->wdir.time = fdir.time;
fptr->wdir.date = fdir.date;
fptr->wdir.size = fdir.size;
fptr->pleft = fptr->prite = 0;
}
else
if (strcmp(fptr->wdir.name,fdir.name) > 0)
fptr->pleft = insert(fptr->pleft,fdir);
else
fptr->prite = insert(fptr->prite,fdir);
return(fptr);
}

static int c_ampm[] = { 'a','p' };
treeprint(p)
TREE *p;
{
char wname[13],wext[4];
char whour,windex;
int wch;

if (p) {
treeprint(p->pleft);
windex = p->wdir.time.hours > 12;
whour = p->wdir.time.hours % 12;
if (! whour) whour = 12;
if (++wcount % 24 == 0) {
printf("\nHit to continue...");
do ; while ((wch = getch() != '\r'));
}

if (strchr(p->wdir.name,'.')) {
jzgetpce(p->wdir.name,wname,'.',1);
jzgetpce(p->wdir.name,wext,'.',2);
}
else {
strcpy(wname,p->wdir.name);
*wext = 0;
}
sprintf(p->wdir.name,"%-8s %-3s",wname,wext);

printf("\n%-12s %7ld %2d-%02d-%02d %2d:%02d%c",
p->wdir.name,p->wdir.size,
p->wdir.date.month,p->wdir.date.day,p->wdir.date.year,
whour,p->wdir.time.mins,c_ampm[windex]);
treeprint(p->prite);
}
}


  3 Responses to “Category : C Source Code
Archive   : JAZ_CLIB.ZIP
Filename : JZDIRLST.DMO

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/