1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2013 Index Data
3 * See the file LICENSE for details.
7 \brief Implement opendir/readdir/closedir on Windows
21 #include <yaz/dirent.h>
27 WIN32_FIND_DATA find_data;
31 DIR *opendir(const char *name)
33 char fullName[MAX_PATH+1];
34 DIR *dd = malloc(sizeof(*dd));
38 strcpy(fullName, name);
39 strcat(fullName, "\\*.*");
40 dd->handle = FindFirstFile(fullName, &dd->find_data);
44 struct dirent *readdir(DIR *dd)
46 if (dd->handle == INVALID_HANDLE_VALUE)
48 strcpy(dd->entry.d_name, dd->find_data.cFileName);
49 if (!FindNextFile(dd->handle, &dd->find_data))
51 FindClose(dd->handle);
52 dd->handle = INVALID_HANDLE_VALUE;
57 void closedir(DIR *dd)
59 if (dd->handle != INVALID_HANDLE_VALUE)
60 FindClose(dd->handle);
70 * c-file-style: "Stroustrup"
71 * indent-tabs-mode: nil
73 * vim: shiftwidth=4 tabstop=8 expandtab