/[svn]/ircd-hybrid/branches/8.2.x/libltdl/lt__dirent.c
ViewVC logotype

Contents of /ircd-hybrid/branches/8.2.x/libltdl/lt__dirent.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5394 - (show annotations)
Tue Jan 20 14:03:09 2015 UTC (7 years, 10 months ago) by michael
File MIME type: text/x-chdr
File size: 3014 byte(s)
- libtool 2.4.5, automake 1.15

1 /* lt__dirent.c -- internal directory entry scanning interface
2
3 Copyright (C) 2001, 2004, 2011-2015 Free Software Foundation, Inc.
4 Written by Bob Friesenhahn, 2001
5
6 NOTE: The canonical source of this file is maintained with the
7 GNU Libtool package. Report bugs to bug-libtool@gnu.org.
8
9 GNU Libltdl is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 As a special exception to the GNU Lesser General Public License,
15 if you distribute this file as part of a program or library that
16 is built using GNU Libtool, you may include this file under the
17 same distribution terms that you use for the rest of that program.
18
19 GNU Libltdl is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with GNU Libltdl; see the file COPYING.LIB. If not, a
26 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
27 or obtained by writing to the Free Software Foundation, Inc.,
28 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 */
30
31 #include "lt__private.h"
32
33 #include <assert.h>
34
35 #include "lt__dirent.h"
36
37 #if defined __WINDOWS__
38
39 void
40 closedir (DIR *entry)
41 {
42 assert (entry != (DIR *) NULL);
43 FindClose (entry->hSearch);
44 free (entry);
45 }
46
47
48 DIR *
49 opendir (const char *path)
50 {
51 char file_spec[LT_FILENAME_MAX];
52 DIR *entry;
53
54 assert (path != (char *) 0);
55 if (lt_strlcpy (file_spec, path, sizeof file_spec) >= sizeof file_spec
56 || lt_strlcat (file_spec, "\\", sizeof file_spec) >= sizeof file_spec)
57 return (DIR *) 0;
58 entry = (DIR *) malloc (sizeof(DIR));
59 if (entry != (DIR *) 0)
60 {
61 entry->firsttime = TRUE;
62 entry->hSearch = FindFirstFile (file_spec, &entry->Win32FindData);
63
64 if (entry->hSearch == INVALID_HANDLE_VALUE)
65 {
66 if (lt_strlcat (file_spec, "\\*.*", sizeof file_spec) < sizeof file_spec)
67 {
68 entry->hSearch = FindFirstFile (file_spec, &entry->Win32FindData);
69 }
70
71 if (entry->hSearch == INVALID_HANDLE_VALUE)
72 {
73 entry = (free (entry), (DIR *) 0);
74 }
75 }
76 }
77
78 return entry;
79 }
80
81
82 struct dirent *
83 readdir (DIR *entry)
84 {
85 int status;
86
87 if (entry == (DIR *) 0)
88 return (struct dirent *) 0;
89
90 if (!entry->firsttime)
91 {
92 status = FindNextFile (entry->hSearch, &entry->Win32FindData);
93 if (status == 0)
94 return (struct dirent *) 0;
95 }
96
97 entry->firsttime = FALSE;
98 if (lt_strlcpy (entry->file_info.d_name, entry->Win32FindData.cFileName,
99 sizeof entry->file_info.d_name) >= sizeof entry->file_info.d_name)
100 return (struct dirent *) 0;
101 entry->file_info.d_namlen = strlen (entry->file_info.d_name);
102
103 return &entry->file_info;
104 }
105
106 #endif /*defined __WINDOWS__*/

Properties

Name Value
svn:eol-style native

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28