home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 6 File
/
06-File.zip
/
FILES202.ZIP
/
FILES.C
next >
Wrap
C/C++ Source or Header
|
1989-03-23
|
3KB
|
139 lines
/* files.c
**
** Copyright (c) 1988-89, Christopher Laforet
** All Rights Reserved
**
** The Programmer's Oasis
** (919) 226-6957
** 9600HST,2400,1200,300-N-8-1
**
** (v1.xx) for Turbo-C
** (v2.xx) for OS/2 - CML 2-89
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <os2.h>
#include "files.h"
unsigned short total_files = 0;
unsigned long total_bytes = 0L;
int verbose_flag = 0;
int directory_flag = 0;
int current_flag = 0;
int modified_flag = 0;
int sort_flag = 1;
int pattern_flag = 0;
main(argc,argv)
int argc;
char *argv[];
{
short count;
unsigned char pattern[20];
unsigned char start[100];
unsigned short drive;
unsigned long drivemap;
fprintf(stdout,"FILES (v %u.%02u of %s): A File/Directory Listing Utility\n",MAJOR_VERSION,MINOR_VERSION,__DATE__);
fprintf(stdout,"Copyright (c) 1988-89, Christopher Laforet. All Rights Reserved.\n");
fprintf(stdout,"Released into the Public Domain 1988.\n\n");
strcpy(pattern,"*.*");
strcpy(start,"");
if (argc > 1)
{
for (count = 1; count < argc; count++)
{
if (*argv[count] == '+')
{
switch (argv[count][1])
{
case 'd':
++directory_flag;
break;
case 'c':
++current_flag;
break;
case 'v':
++verbose_flag;
break;
default:
fprintf(stderr,"Unknown option +%c\n",argv[count][1]);
break;
}
}
else if (*argv[count] == '-')
{
switch (argv[count][1])
{
case 's':
sort_flag = 0;
break;
case 'h':
case '?':
usage();
break;
default:
fprintf(stderr,"Unknown option -%c\n",argv[count][1]);
break;
}
}
else if (!(strncmp(argv[count],"p=",2)))
{
strcpy(pattern,&argv[count][2]);
++pattern_flag;
}
else if (*argv[count] == '?')
{
usage();
}
else if (count == 1)
{
strcpy(start,argv[1]);
if ((strlen(start) == 1) && (start[0] == '\\'))
{
if (!DosQCurDisk(&drive,&drivemap))
{
sprintf(start,"%c:",'A' + (drive - 1));
}
}
else if (start[strlen(start) - 1] == '\\')
{
start[strlen(start) - 1] = 0;
}
}
}
}
if (verbose_flag)
{
fprintf(stdout,"Attrib FileSize Date Time Name\n\n");
}
else
{
fprintf(stdout,"FileSize Date Time Name\n\n");
}
getfile(start,pattern);
fprintf(stdout,"\nTotal Files Found: %u\nTotal Bytes in Files: %lu\nTotal Free Space on Disk: %lu\n\n",total_files,total_bytes,get_disk_space(start));
return(0);
}
void usage()
{
fprintf(stdout,"Usage is: files [start-directory] [options]\n");
fprintf(stdout," where \"options\" are:\n");
fprintf(stdout,"\t+c - current directory only\n");
fprintf(stdout,"\t+d - list directories only\n");
fprintf(stdout,"\t-s - do not sort listings\n");
fprintf(stdout,"\t+v - verbose listing (include attributes)\n");
fprintf(stdout,"\t p=pattern where pattern can include * and ?\n\n");
exit(1);
}