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 License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * 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
23 #include "libguile/__scm.h"
29 #include "win32-dirent.h"
32 opendir (const char * name
)
41 file
= malloc (strlen (name
) + 3);
43 if (file
[strlen (name
) - 1] != '/' && file
[strlen (name
) - 1] != '\\')
48 if ((hnd
= FindFirstFile (file
, &find
)) == INVALID_HANDLE_VALUE
)
54 dir
= malloc (sizeof (DIR));
57 dir
->data
= malloc (sizeof (WIN32_FIND_DATA
));
58 dir
->allocation
= sizeof (WIN32_FIND_DATA
);
59 dir
->size
= dir
->allocation
;
61 memcpy (dir
->data
, &find
, sizeof (WIN32_FIND_DATA
));
68 static struct dirent entry
;
69 WIN32_FIND_DATA
*find
;
73 find
= (WIN32_FIND_DATA
*) dir
->data
;
77 if (!FindNextFile ((HANDLE
) dir
->fd
, find
))
81 entry
.d_off
= dir
->filepos
;
82 strncpy (entry
.d_name
, find
->cFileName
, sizeof (entry
.d_name
));
83 entry
.d_reclen
= strlen (find
->cFileName
);
91 HANDLE hnd
= (HANDLE
) dir
->fd
;
95 return FindClose (hnd
) ? 0 : -1;
101 HANDLE hnd
= (HANDLE
) dir
->fd
;
102 WIN32_FIND_DATA
*find
= (WIN32_FIND_DATA
*) dir
->data
;
105 hnd
= FindFirstFile (dir
->mask
, find
);
111 seekdir (DIR * dir
, off_t offset
)
116 for (n
= 0; n
< offset
; n
++)
118 if (FindNextFile ((HANDLE
) dir
->fd
, (WIN32_FIND_DATA
*) dir
->data
))