1 /* Copyright (C) 2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #include "libguile/__scm.h"
24 #include "win32-dirent.h"
27 opendir (const char * name
)
36 file
= malloc (strlen (name
) + 3);
38 if (file
[strlen (name
) - 1] != '/' && file
[strlen (name
) - 1] != '\\')
43 if ((hnd
= FindFirstFile (file
, &find
)) == INVALID_HANDLE_VALUE
)
49 dir
= malloc (sizeof (DIR));
52 dir
->data
= malloc (sizeof (WIN32_FIND_DATA
));
53 dir
->allocation
= sizeof (WIN32_FIND_DATA
);
54 dir
->size
= dir
->allocation
;
56 memcpy (dir
->data
, &find
, sizeof (WIN32_FIND_DATA
));
63 static struct dirent entry
;
64 WIN32_FIND_DATA
*find
;
68 find
= (WIN32_FIND_DATA
*) dir
->data
;
72 if (!FindNextFile ((HANDLE
) dir
->fd
, find
))
76 entry
.d_off
= dir
->filepos
;
77 strncpy (entry
.d_name
, find
->cFileName
, sizeof (entry
.d_name
));
78 entry
.d_reclen
= strlen (find
->cFileName
);
86 HANDLE hnd
= (HANDLE
) dir
->fd
;
90 return FindClose (hnd
) ? 0 : -1;
96 HANDLE hnd
= (HANDLE
) dir
->fd
;
97 WIN32_FIND_DATA
*find
= (WIN32_FIND_DATA
*) dir
->data
;
100 hnd
= FindFirstFile (dir
->mask
, find
);
106 seekdir (DIR * dir
, off_t offset
)
111 for (n
= 0; n
< offset
; n
++)
113 if (FindNextFile ((HANDLE
) dir
->fd
, (WIN32_FIND_DATA
*) dir
->data
))