1 /*
2 Copyright (C) 2015-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4dir.ctr
12 */
13 
14 /**	@file dk4dir.c The dk4dir module.
15 */
16 
17 
18 #include "dk4conf.h"
19 #include <libdk4c/dk4dir.h>
20 #if DK4_CHAR_SIZE > 1
21 #include <libdk4c/dk4dirwc.h>
22 #else
23 #include <libdk4c/dk4dir08.h>
24 #endif
25 
26 #if	DK4_HAVE_ASSERT_H
27 #ifndef	ASSERT_H_INCLUDED
28 #include <assert.h>
29 #define	ASSERT_H_INCLUDED 1
30 #endif
31 #endif
32 
33 
34 dk4_dir_t *
dk4dir_open(const dkChar * path,int om,dk4_er_t * erp)35 dk4dir_open(const dkChar *path, int om, dk4_er_t *erp)
36 {
37 #if	DK4_USE_ASSERT
38   assert(NULL != path);
39 #endif
40 #if DK4_CHAR_SIZE > 1
41   return (dk4dir_wc_open(path, om, erp));
42 #else
43   return (dk4dir_c8_open(path, om, erp));
44 #endif
45 }
46 
47 
48 
49 void
dk4dir_close(dk4_dir_t * dptr)50 dk4dir_close(dk4_dir_t *dptr)
51 {
52 #if	DK4_USE_ASSERT
53   assert(NULL != dptr);
54 #endif
55 #if DK4_CHAR_SIZE > 1
56   dk4dir_wc_close(dptr);
57 #else
58   dk4dir_c8_close(dptr);
59 #endif
60 }
61 
62 
63 
64 void
dk4dir_reset(dk4_dir_t * dptr)65 dk4dir_reset(dk4_dir_t *dptr)
66 {
67 #if	DK4_USE_ASSERT
68   assert(NULL != dptr);
69 #endif
70 #if DK4_CHAR_SIZE > 1
71   dk4dir_wc_reset(dptr);
72 #else
73   dk4dir_c8_reset(dptr);
74 #endif
75 }
76 
77 
78 
79 const dkChar *
dk4dir_get_path(dk4_dir_t const * dptr)80 dk4dir_get_path(dk4_dir_t const *dptr)
81 {
82 #if	DK4_USE_ASSERT
83   assert(NULL != dptr);
84 #endif
85 #if DK4_CHAR_SIZE > 1
86   return (dk4dir_wc_get_path(dptr));
87 #else
88   return (dk4dir_c8_get_path(dptr));
89 #endif
90 }
91 
92 
93 
94 const dkChar *
dk4dir_next_dir(dk4_dir_t * dptr)95 dk4dir_next_dir(dk4_dir_t *dptr)
96 {
97 #if	DK4_USE_ASSERT
98   assert(NULL != dptr);
99 #endif
100 #if DK4_CHAR_SIZE > 1
101   return (dk4dir_wc_next_dir(dptr));
102 #else
103   return (dk4dir_c8_next_dir(dptr));
104 #endif
105 }
106 
107 
108 
109 const dkChar *
dk4dir_next_file(dk4_dir_t * dptr)110 dk4dir_next_file(dk4_dir_t *dptr)
111 {
112 #if	DK4_USE_ASSERT
113   assert(NULL != dptr);
114 #endif
115 #if DK4_CHAR_SIZE > 1
116   return (dk4dir_wc_next_file(dptr));
117 #else
118   return (dk4dir_c8_next_file(dptr));
119 #endif
120 }
121 
122 
123 
124 
125 void
dk4dir_skip_files(dk4_dir_t * dptr)126 dk4dir_skip_files(dk4_dir_t *dptr)
127 {
128 #if	DK4_USE_ASSERT
129   assert(NULL != dptr);
130 #endif
131 #if DK4_CHAR_SIZE > 1
132   dk4dir_wc_skip_files(dptr);
133 #else
134   dk4dir_c8_skip_files(dptr);
135 #endif
136 }
137 
138 
139 
140 size_t
dk4dir_get_max_entry_length(dk4_dir_t const * dptr)141 dk4dir_get_max_entry_length(dk4_dir_t const *dptr)
142 {
143 #if	DK4_USE_ASSERT
144   assert(NULL != dptr);
145 #endif
146 #if DK4_CHAR_SIZE > 1
147   return (dk4dir_wc_get_max_entry_length(dptr));
148 #else
149   return (dk4dir_c8_get_max_entry_length(dptr));
150 #endif
151 }
152 
153 
154 
155 int
dk4dir_full_name_buffer(dkChar * buffer,size_t szbuf,dk4_dir_t const * pdir,dkChar const * fn,dk4_er_t * erp)156 dk4dir_full_name_buffer(
157   dkChar		*buffer,
158   size_t		 szbuf,
159   dk4_dir_t	const	*pdir,
160   dkChar	const	*fn,
161   dk4_er_t		*erp
162 )
163 {
164 #if	DK4_USE_ASSERT
165   assert(NULL != pdir);
166   assert(NULL != fn);
167   assert(NULL != buffer);
168   assert(0 < szbuf);
169 #endif
170 #if	DK4_CHAR_SIZE > 1
171   return (
172     dk4dir_wc_full_name_buffer(buffer, szbuf, pdir, fn, erp)
173   );
174 #else
175   return (
176     dk4dir_c8_full_name_buffer(buffer, szbuf, pdir, fn, erp)
177   );
178 #endif
179 }
180 
181 
182 
183 dkChar *
dk4dir_full_name_new(dk4_dir_t const * pdir,dkChar const * fn,dk4_er_t * erp)184 dk4dir_full_name_new(
185   dk4_dir_t	const	*pdir,
186   dkChar	const	*fn,
187   dk4_er_t		*erp
188 )
189 {
190 #if	DK4_USE_ASSERT
191   assert(NULL != pdir);
192   assert(NULL != fn);
193 #endif
194 #if	DK4_CHAR_SIZE > 1
195   return (
196     dk4dir_wc_full_name_new(pdir, fn, erp)
197   );
198 #else
199   return (
200     dk4dir_c8_full_name_new(pdir, fn, erp)
201   );
202 #endif
203 }
204 
205 
206 
207