WORKSHOP\FD.C ·
C ·
1.7 KB ·
1988-11-22 ·
from PersonalComputing_Feb-1989
/*
This program prints out a full directory including hidden files
complete with file attributes.
By P Brough
*/
#include <dos.h>
#include <stdio.h>
main(argc,argv)
int argc;
char *argv[];
{
int file_count=0,sub_count=0;
long total_bytes=0;
char cwd[65];
struct FIND *p;
printf(" ╔═══════════════════════════════════════════════════╗\n");
printf(" ║FD - A Full Directory Listing - By Philip Brough ║\n");
printf(" ╚═══════════════════════════════════════════════════╝\n");
system(" vol");
getcwd(cwd,65);
printf("\n Directory of :%s",cwd);
printf(" \n Filename Size Date Time Attributes\n");
printf(" ───────────────────────────────────────────────────────────────────────────────\n");
if (argc==1)
p = findfirst("*.*",0xFF);
else
{
p = findfirst(argv[1],0xFF);
}
while(p)
{
if (p->attribute & 0x10)
printf( "\n%-12s <DIR> ",p->name);
else
printf( "\n%-12s\t%-8lu ",p->name,p->size);
printf(" %02d-%02d-%02d %02d:%02d ",(p->date)&31,
(p->date)>>5&15,((p->date)>>9)+80,
(p->time>>11),((p->time)>>5)&63);
{
if (p->attribute & 0x01)
printf("Read-Only ");
if (p->attribute & 0x02)
printf("Hidden ");
if (p->attribute & 0x04)
printf("System ");
if (p->attribute & 0x10)
{
printf("Subdirectory ");
sub_count++;
}
if (p->attribute &0x20)
printf("Archive ");
}
file_count++;
total_bytes += p->size;
p=findnext();
}
printf("\n %d files containing %ld bytes",file_count,total_bytes);
printf("\n %d Subdirectories found",sub_count);
}