1 /* Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libguile/__scm.h"
28 #include "win32-dirent.h"
31 opendir (const char * name)
40 file = malloc (strlen (name) + 3);
42 if (file[strlen (name) - 1] != '/' && file[strlen (name) - 1] != '\\')
47 if ((hnd = FindFirstFile (file, &find)) == INVALID_HANDLE_VALUE)
53 dir = malloc (sizeof (DIR));
56 dir->data = malloc (sizeof (WIN32_FIND_DATA));
57 dir->allocation = sizeof (WIN32_FIND_DATA);
58 dir->size = dir->allocation;
60 memcpy (dir->data, &find, sizeof (WIN32_FIND_DATA));
67 static struct dirent entry;
68 WIN32_FIND_DATA *find;
72 find = (WIN32_FIND_DATA *) dir->data;
76 if (!FindNextFile ((HANDLE) dir->fd, find))
80 entry.d_off = dir->filepos;
81 strncpy (entry.d_name, find->cFileName, sizeof (entry.d_name));
82 entry.d_reclen = strlen (find->cFileName);
90 HANDLE hnd = (HANDLE) dir->fd;
94 return FindClose (hnd) ? 0 : -1;
100 HANDLE hnd = (HANDLE) dir->fd;
101 WIN32_FIND_DATA *find = (WIN32_FIND_DATA *) dir->data;
104 hnd = FindFirstFile (dir->mask, find);
110 seekdir (DIR * dir, off_t offset)
115 for (n = 0; n < offset; n++)
117 if (FindNextFile ((HANDLE) dir->fd, (WIN32_FIND_DATA *) dir->data))