1 /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
3 * Copyright 2011 Andrea Canciani
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * the authors not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. The authors make no representations about the
13 * suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty.
16 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL,
19 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
22 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: Andrea Canciani <ranma42@gmail.com>
27 #include "cairo-compiler-private.h"
29 #define WIN32_LEAN_AND_MEAN
34 #define S_ISDIR(s) ((s) & _S_IFDIR)
38 char d_name[FILENAME_MAX + 1];
43 cairo_bool_t has_next;
49 opendir(const char *dirname)
53 dirp = malloc (sizeof (*dirp));
54 if (unlikely (dirp == NULL))
57 dirp->handle = FindFirstFile(dirname, &dirp->data);
59 if (unlikely (dirp->handle == INVALID_HANDLE_VALUE)) {
64 memcpy (dirp->de.d_name, dirp->data.cFileName,
65 sizeof (dirp->data.cFileName));
66 dirp->de.d_name[FILENAME_MAX] = '\0';
68 dirp->has_next = TRUE;
78 ret = ! FindClose (dirp->handle);
87 static struct dirent *
93 /* COMPILE_TIME_ASSERT (FILENAME_MAX == sizeof (dirp->data.cFileName)); */
95 memcpy (dirp->de.d_name, dirp->data.cFileName,
96 sizeof (dirp->data.cFileName));
97 dirp->de.d_name[FILENAME_MAX] = '\0';
99 dirp->has_next = FindNextFile (dirp->handle, &dirp->data);