Category : File Managers
Archive   : DIRDIR.ZIP
Filename : DD.C

 
Output of file : DD.C contained in archive : DIRDIR.ZIP
/* DD.c - DirDir
**
** Gives list of subdirs. for any given path, or current drive/dir if
** none specified.
**
** Usage: dd [drive][path]
**
** This source code is completely free of restrictions. Help yourself!
** -Wayne Smith jul 90
*/

#include
#include
#include
#include

/************************************************************************
file attributes (defined in DOS.H):
FA_RDONLY = 00000001 = 1
FA_HIDDEN = 00000010 = 2
FA_SYSTEM = 00000100 = 4
FA_LABEL = 00001000 = 8
FA_DIREC = 00010000 = 16
FA_ARCH = 00100000 = 32

--> however: archive, read-only, and no-attribute files always shown.
***************************************************************************/

struct ffblk dta; /* maps DOS DTA fields */
char attrib_buf[7];
char datebuf[9];
char timebuf[9];
char namebuf[13];

union {
unsigned int i;
struct {
unsigned day: 5;
unsigned mon: 4;
unsigned year: 7;
} fd;
} ud;

union {
unsigned int i;
struct file_time {
unsigned sec: 5;
unsigned min: 6;
unsigned hour: 5;
} ft;
} ut;

void getfstats (void);

int main (int argc, char **argv)
{
int done;
char *ptr;
char path[80];


if (argc > 1)
strcpy (path, argv[1]);
else if (getcwd (path, 80) == NULL)
return (-1);
for (ptr=path; *ptr; ptr++);
switch (*(--ptr)) {
case '*':
if (*(ptr-1) != '.')
strcat (path, ".*");
break;
case '.':
strcat (path, "*");
break;
case '\\':
strcat (path, "*.*");
break;
default:
strcat (path, "\\*.*");
}
printf ("%s\n", path);

done = findfirst (path, &dta, FA_HIDDEN | FA_SYSTEM | FA_DIREC | FA_LABEL);
if (!strcmp (dta.ff_name, "DEVELOPM.ENT")) {
getfstats ();
printf (" %-13s%10s%8s %s attrib: %d\n", dta.ff_name, datebuf,
timebuf, attrib_buf, dta.ff_attrib);
}
while (!done)
{
/* skip the non-dir, ., && .. files */
if ((dta.ff_attrib & FA_DIREC) && dta.ff_name[0] != '.')
{
getfstats ();
printf (" %-13s%10s%8s %s\n", dta.ff_name,
datebuf, timebuf, attrib_buf);
}
done = findnext(&dta);
}

if (errno == ENOENT) {
fprintf( stderr, "\nNo such file or subdirectory.\n");
return (-1);
}
return (0);
}

void getfstats (void)
{
int i;
char pm, *src; /* *dest; */

/* translate attributes */
src = attrib_buf;
if (dta.ff_attrib & FA_ARCH) *src++ = 'a'; else *src++ = '.';
if (dta.ff_attrib & FA_RDONLY) *src++ = 'r'; else *src++ = '.';
if (dta.ff_attrib & FA_HIDDEN) *src++ = 'h'; else *src++ = '.';
if (dta.ff_attrib & FA_SYSTEM) *src++ = 's'; else *src++ = '.';
/* if (dta.ff_attrib & FA_DIREC) *src++ = 'd'; else *src++ = '.'; */
if (dta.ff_attrib & FA_LABEL) *src++ = 'v'; else *src++ = '.';

/* translate time stamp */
ut.i = dta.ff_ftime;
/* sprintf (timebuf, "%02d:%02d:%02d", ut.ft.hour, ut.ft.min,r
ut.ft.sec * 2);
*/
if (ut.ft.hour > 12)
pm = 'p';
else
pm = 'a';
sprintf (timebuf, "%2d:%02d%c", ut.ft.hour - (12 * (pm == 'p')),
ut.ft.min, pm);

/* translate date stamp */
ud.i = dta.ff_fdate;
sprintf( datebuf, "%d-%02d-%d", ud.fd.mon, ud.fd.day, ud.fd.year+80);

#ifdef ZULU
/* reformat file name */
src = dta.ff_name;
dest = namebuf;
for (i=0; i<8; i++) {
if (*src != '.' && *src)
*dest++ = *src++;
else
*dest++ = ' ';
}
while (*src)
*dest++ = *src++;
*dest = '\0';
#endif ZULU
}


  3 Responses to “Category : File Managers
Archive   : DIRDIR.ZIP
Filename : DD.C

  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/