home *** CD-ROM | disk | FTP | other *** search
- /* sys/filefind.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
-
- #include <sys/emx.h>
- #include <string.h>
- #include <errno.h>
- #include <os2emx.h>
- #include "syscalls.h"
-
- static HDIR find_handle;
- static ULONG find_count;
- static FILEFINDBUF3 find_buf;
-
- static int find_conv (struct _find *fp)
- {
- if (find_count != 1)
- {
- errno = ENOENT;
- return (-1);
- }
- fp->attr = (unsigned char)find_buf.attrFile;
- fp->time = *(unsigned short *)&find_buf.ftimeLastWrite;
- fp->date = *(unsigned short *)&find_buf.fdateLastWrite;
- fp->size_lo = (unsigned short)(find_buf.cbFile & 0xffff);
- fp->size_hi = (unsigned short)(find_buf.cbFile >> 16);
- strcpy (fp->name, find_buf.achName);
- return (0);
- }
-
-
- int __findfirst (const char *name, int attr, struct _find *fp)
- {
- ULONG rc;
-
- find_handle = HDIR_SYSTEM;
- find_count = 1;
- rc = DosFindFirst (name, &find_handle, attr & 0x37,
- &find_buf, sizeof (find_buf),
- &find_count, 1);
- if (rc != 0)
- {
- _sys_set_errno (rc);
- return (-1);
- }
- return (find_conv (fp));
- }
-
-
- int __findnext (struct _find *fp)
- {
- ULONG rc;
-
- find_count = 1;
- rc = DosFindNext (find_handle, &find_buf, sizeof (find_buf), &find_count);
- if (rc != 0)
- {
- _sys_set_errno (rc);
- return (-1);
- }
- return (find_conv (fp));
- }
-