home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 19 Printer
/
19-Printer.zip
/
lj2up2.zip
/
FSEARCH.C
next >
Wrap
Text File
|
1988-07-12
|
2KB
|
85 lines
/*
** File functions FSEARCH and FNEXT.
**
**
** Joe Barnhart, 21-July-86
** Steve Coles, 19-October-87 changed for OS/2
** Steve Coles, 12-July-88 changed to MSC 1.1 headers
*/
/* Prototypes */
char *fsearch(char *fname);
char *fnext(void );
char *fpath(char *fname);
#define INCL_NOCOMMON /* These three lines define how much */
#define INCL_DOSFILEMGR /* of the OS/2 API is defined. In this */
#include <os2.h> /* only file functions. */
/* Standard C includes */
#include <string.h>
HDIR dhand; /* search handle */
FILEFINDBUF wbuf; /* OS/2 places directory info */
USHORT nwbuf = 1; /* number of directories */
char *fsearch( fname )
char *fname;
{
unsigned rc;
dhand = 0xffff; /* let OS assign handle */
rc = DosFindFirst(fname,
&dhand,
0,
&wbuf,
sizeof(wbuf),
&nwbuf,
0L);
if (rc == 0)
return(strlwr(wbuf.achName));
return(0);
}
char *fnext()
{
unsigned rc;
rc = DosFindNext(dhand,
&wbuf,
sizeof(wbuf),
&nwbuf);
if (rc == 0)
return(strlwr(wbuf.achName));
return(0);
}
char *fpath( fname )
char *fname;
{
static char path[32];
register int plen;
register char *p;
char *endp;
for( p=fname, endp=fname; *p!='\0'; p++ )
if( *p==':' || *p=='\\' )
endp = p+1;
plen = endp - fname;
if( plen == 0 )
path[0] = '\0';
else {
strncpy( path, fname, plen );
path[ plen+1 ] = '\0';
strlwr( path );
}
return( path );
}