2 * Copyright (C) 1997-2002, Index Data
5 * $Id: dirent.c,v 1.5 2002-04-04 20:50:37 adam Exp $
7 * This utility implements a opendir/readdir/close on Windows.
24 WIN32_FIND_DATA find_data;
28 DIR *opendir (const char *name)
30 char fullName[MAX_PATH+1];
31 DIR *dd = malloc (sizeof(*dd));
35 strcpy (fullName, name);
36 strcat (fullName, "\\*.*");
37 dd->handle = FindFirstFile(fullName, &dd->find_data);
41 struct dirent *readdir (DIR *dd)
43 if (dd->handle == INVALID_HANDLE_VALUE)
45 strcpy (dd->entry.d_name, dd->find_data.cFileName);
46 if (!FindNextFile(dd->handle, &dd->find_data))
48 FindClose (dd->handle);
49 dd->handle = INVALID_HANDLE_VALUE;
54 void closedir(DIR *dd)
56 if (dd->handle != INVALID_HANDLE_VALUE)
57 FindClose (dd->handle);