1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
/*
Copyright (C) 2015-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/
/*
WARNING: This file was generated by the dkct program (see
http://dktools.sourceforge.net/ for details).
Changes you make here will be lost if dkct is run again!
You should modify the original source and run dkct on it.
Original source: dk4file8.ctr
*/
/** @file dk4file8.c The dk4file8 module.
*/
#line 103 "dk4file8.ctr"
#include "dk4conf.h"
#include "dk4types.h"
#if DK4_ON_WINDOWS
#ifndef WINDOWS_H_INCLUDED
#include <windows.h>
#define WINDOWS_H_INCLUDED 1
#endif
#else
#ifndef DK4STAT8_H_INCLUDED
#include "dk4stat8.h"
#endif
#ifndef DK4STAT_H_INCLUDED
#include "dk4stat.h"
#endif
#endif
#include "dk4file8.h"
#if DK4_HAVE_ASSERT_H
#ifndef ASSERT_H_INCLUDED
#include <assert.h>
#define ASSERT_H_INCLUDED 1
#endif
#endif
#line 132 "dk4file8.ctr"
int
dk4file_c8_exists(const char *fn, dk4_er_t *erp)
{
#if DK4_ON_WINDOWS
DWORD dwattr;
HANDLE ha;
WIN32_FIND_DATAA ffdata;
#else
dk4_stat_t stb;
dk4_stat_t lstb;
#endif
int back = 0;
#if DK4_USE_ASSERT
assert(NULL != fn);
#endif
if (NULL != fn) {
#if DK4_ON_WINDOWS
dwattr = GetFileAttributesA(fn);
if (INVALID_FILE_ATTRIBUTES != dwattr) {
back = 1;
} else {
ha = FindFirstFileA(fn, &ffdata);
if (INVALID_HANDLE_VALUE != ha) {
back = 1;
FindClose(ha);
} else {
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
}
#else
if (0 != dk4stat_c8(&stb, fn, NULL)) {
back = 1;
} else {
if (0 != dk4stat_l_c8(&lstb, fn, NULL)) {
back = 1;
} else {
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
}
#endif
} else {
dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
}
return back;
}
int
dk4file_c8_is_regular(const char *fn, dk4_er_t *erp)
{
#if DK4_ON_WINDOWS
DWORD dwattr;
HANDLE ha;
WIN32_FIND_DATAA ffdata;
#else
dk4_stat_t stb;
#endif
int back = 0;
#line 195 "dk4file8.ctr"
#if DK4_USE_ASSERT
assert(NULL != fn);
#endif
if (NULL != fn) {
#line 199 "dk4file8.ctr"
#if DK4_ON_WINDOWS
dwattr = GetFileAttributesA(fn);
if (INVALID_FILE_ATTRIBUTES != dwattr) {
if ((DWORD)0UL == (FILE_ATTRIBUTE_DIRECTORY & dwattr)) {
if ((DWORD)0UL == (FILE_ATTRIBUTE_DEVICE & dwattr)) {
back = 1;
}
}
} else {
ha = FindFirstFileA(fn, &ffdata);
if (INVALID_HANDLE_VALUE != ha) {
dwattr = ffdata.dwFileAttributes;
if ((DWORD)0UL == (FILE_ATTRIBUTE_DIRECTORY & dwattr)) {
if ((DWORD)0UL == (FILE_ATTRIBUTE_DEVICE & dwattr)) {
back = 1;
}
}
FindClose(ha);
} else {
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
}
#else
#line 223 "dk4file8.ctr"
if (0 != dk4stat_c8(&stb, fn, NULL)) {
#line 224 "dk4file8.ctr"
if (0 != dk4stat_is_regular(&stb, erp)) {
#line 225 "dk4file8.ctr"
back = 1;
}
#if TRACE_DEBUG
else {
#line 229 "dk4file8.ctr"
}
#endif
} else {
#line 232 "dk4file8.ctr"
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
#endif
} else {
#line 236 "dk4file8.ctr"
dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
}
#line 239 "dk4file8.ctr"
return back;
}
int
dk4file_c8_is_directory(const char *fn, dk4_er_t *erp)
{
#if DK4_ON_WINDOWS
DWORD dwattr;
HANDLE ha;
WIN32_FIND_DATAA ffdata;
#else
dk4_stat_t stb;
#endif
int back = 0;
#line 256 "dk4file8.ctr"
#if DK4_USE_ASSERT
assert(NULL != fn);
#endif
if (NULL != fn) {
#if DK4_ON_WINDOWS
dwattr = GetFileAttributesA(fn);
if (INVALID_FILE_ATTRIBUTES != dwattr) {
if ((DWORD)0UL != (FILE_ATTRIBUTE_DIRECTORY & dwattr)) {
back = 1;
}
} else {
ha = FindFirstFileA(fn, &ffdata);
if (INVALID_HANDLE_VALUE != ha) {
dwattr = ffdata.dwFileAttributes;
if ((DWORD)0UL!=(FILE_ATTRIBUTE_DIRECTORY & dwattr))
{
back = 1;
}
FindClose(ha);
} else {
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
}
#else
if (0 != dk4stat_c8(&stb, fn, NULL)) {
if (0 != dk4stat_is_directory(&stb, erp)) {
back = 1;
}
} else {
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
#endif
} else {
dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
}
#line 292 "dk4file8.ctr"
return back;
}
|