home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 9 Archive
/
09-Archive.zip
/
OS2ARC_S.ZIP
/
ARCDIR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1987-10-16
|
3KB
|
75 lines
/* ARC - Archive utility - ARCDIR
$define(tag,$$segment(@1,$$index(@1,=)+1))#
$define(version,Version $tag(
TED_VERSION DB =1.02), created on $tag(
TED_DATE DB =02/04/86) at $tag(
TED_TIME DB =01:36:09))#
$undefine(tag)#
$version
(C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
By: Thom Henderson
Description:
This file contains the dir() routine used when adding files to an
archive. It is an adaptation of the CI-C86 library function
filedir(). It differes in that it returns the file names one by
one, instead of all at once.
Language:
Computer Innovations Optimizing C86
*/
#include <stdio.h>
extern far pascal DOSFINDFIRST(char far *, int far *, int, char far *,
int, int far *, unsigned long);
extern far pascal DOSFINDNEXT(int, char far *, int, int far *);
static struct
{
unsigned int cdate,ctime; /* creation date/time */
unsigned int adate,atime; /* accessed date/time */
unsigned int wdate,wtime; /* write date/time */
unsigned long filesize; /* size */
unsigned long filealloc; /* allocation */
unsigned int attribute; /* attribute */
unsigned char namelength; /* length of name */
unsigned char fn[15]; /* file name storage */
} ff_area;
static int dirhandle = 1; /* directory search handle */
char *dir(filename,mode) /* get files, one by one */
char *filename; /* template, or NULL */
int mode; /* search mode bits */
{
char *result, *alloc();/*mpl*/
static int first = 1; /* true only on first call */
int sf_mode = 1; /* search first mode */
int num2find = 1; /* how many to find */
int res;
if(filename) /* if filename is given */
{
res = DOSFINDFIRST((char far *) filename,(int far *) &dirhandle,
mode, (char far *) &ff_area, sizeof(ff_area),
(int far *) &num2find,0L);
if (res) return NULL;
}
else if(first) /* if no name and first call */
return NULL; /* then not much we can do */
else {
res = DOSFINDNEXT(dirhandle,(char far *) &ff_area, sizeof(ff_area),
&num2find);
if (res) return NULL;
}
first = 0; /* no longer first time */
result = alloc(strlen(ff_area.fn)+1);/*mpl*/
strcpy(result,ff_area.fn); /* save name of file */
return result;
}