Debian Codegraph @

libcfile/libcfile_file.h

raw symbols SCIP
1 /*
2 * File functions
3 *
4 * Copyright (C) 2008-2024, Joachim Metz <[email protected]>
5 *
6 * Refer to AUTHORS for acknowledgements.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #if !defined( _LIBCFILE_FILE_H )
23 #define _LIBCFILE_FILE_H
24
25 #include <common.h>
26 #include <types.h>
27
28 #include "libcfile_extern.h"
29 #include "libcfile_libcerror.h"
30 #include "libcfile_types.h"
31
32 #if defined( __cplusplus )
33 extern "C" {
34 #endif
35
36 typedef struct libcfile_internal_file libcfile_internal_file_t;
37
38 struct libcfile_internal_file
39 {
40 #if defined( WINAPI )
41
42 /* The (file) handle
43 */
44 HANDLE handle;
45
46 /* Value to indicate the filename indicate this is a device file
47 */
48 uint8_t is_device_filename;
49
50 /* Value to indicate asynchronous IO should be used.
51 */
52 uint8_t use_asynchronous_io;
53 #else
54 /* The (file) descriptor
55 */
56 int descriptor;
57
58 #endif /* defined( WINAPI ) */
59
60 /* The access flags
61 */
62 int access_flags;
63
64 /* The size
65 */
66 size64_t size;
67
68 /* The current offset
69 */
70 off64_t current_offset;
71
72 /* The block size
73 */
74 size_t block_size;
75
76 /* The block data
77 */
78 uint8_t *block_data;
79
80 /* The block data offset
81 */
82 size_t block_data_offset;
83
84 /* The block data size
85 */
86 size_t block_data_size;
87 };
88
89 LIBCFILE_EXTERN \
90 int libcfile_file_initialize(
91 libcfile_file_t **file,
92 libcerror_error_t **error );
93
94 LIBCFILE_EXTERN \
95 int libcfile_file_free(
96 libcfile_file_t **file,
97 libcerror_error_t **error );
98
99 LIBCFILE_EXTERN \
100 int libcfile_file_open(
101 libcfile_file_t *file,
102 const char *filename,
103 int access_flags,
104 libcerror_error_t **error );
105
106 LIBCFILE_EXTERN \
107 int libcfile_file_open_with_error_code(
108 libcfile_file_t *file,
109 const char *filename,
110 int access_flags,
111 uint32_t *error_code,
112 libcerror_error_t **error );
113
114 #if defined( HAVE_WIDE_CHARACTER_TYPE )
115
116 LIBCFILE_EXTERN \
117 int libcfile_file_open_wide(
118 libcfile_file_t *file,
119 const wchar_t *filename,
120 int access_flags,
121 libcerror_error_t **error );
122
123 LIBCFILE_EXTERN \
124 int libcfile_file_open_wide_with_error_code(
125 libcfile_file_t *file,
126 const wchar_t *filename,
127 int access_flags,
128 uint32_t *error_code,
129 libcerror_error_t **error );
130
131 #endif /* defined( HAVE_WIDE_CHARACTER_TYPE ) */
132
133 LIBCFILE_EXTERN \
134 int libcfile_file_close(
135 libcfile_file_t *file,
136 libcerror_error_t **error );
137
138 LIBCFILE_EXTERN \
139 ssize_t libcfile_file_read_buffer(
140 libcfile_file_t *file,
141 uint8_t *buffer,
142 size_t size,
143 libcerror_error_t **error );
144
145 #if defined( WINAPI )
146
147 ssize_t libcfile_internal_file_read_buffer_at_offset_with_error_code(
148 libcfile_internal_file_t *internal_file,
149 off64_t current_offset,
150 uint8_t *buffer,
151 size_t size,
152 uint32_t *error_code,
153 libcerror_error_t **error );
154
155 #endif /* defined( WINAPI ) */
156
157 LIBCFILE_EXTERN \
158 ssize_t libcfile_file_read_buffer_with_error_code(
159 libcfile_file_t *file,
160 uint8_t *buffer,
161 size_t size,
162 uint32_t *error_code,
163 libcerror_error_t **error );
164
165 LIBCFILE_EXTERN \
166 ssize_t libcfile_file_write_buffer(
167 libcfile_file_t *file,
168 const uint8_t *buffer,
169 size_t size,
170 libcerror_error_t **error );
171
172 LIBCFILE_EXTERN \
173 ssize_t libcfile_file_write_buffer_with_error_code(
174 libcfile_file_t *file,
175 const uint8_t *buffer,
176 size_t size,
177 uint32_t *error_code,
178 libcerror_error_t **error );
179
180 LIBCFILE_EXTERN \
181 off64_t libcfile_file_seek_offset(
182 libcfile_file_t *file,
183 off64_t offset,
184 int whence,
185 libcerror_error_t **error );
186
187 LIBCFILE_EXTERN \
188 int libcfile_file_resize(
189 libcfile_file_t *file,
190 size64_t size,
191 libcerror_error_t **error );
192
193 LIBCFILE_EXTERN \
194 int libcfile_file_is_open(
195 libcfile_file_t *file,
196 libcerror_error_t **error );
197
198 LIBCFILE_EXTERN \
199 int libcfile_file_get_offset(
200 libcfile_file_t *file,
201 off64_t *offset,
202 libcerror_error_t **error );
203
204 int libcfile_internal_file_get_size(
205 libcfile_internal_file_t *internal_file,
206 size64_t *size,
207 libcerror_error_t **error );
208
209 LIBCFILE_EXTERN \
210 int libcfile_file_get_size(
211 libcfile_file_t *file,
212 size64_t *size,
213 libcerror_error_t **error );
214
215 LIBCFILE_EXTERN \
216 int libcfile_file_is_device(
217 libcfile_file_t *file,
218 libcerror_error_t **error );
219
220 ssize_t libcfile_internal_file_io_control_read_with_error_code(
221 libcfile_internal_file_t *internal_file,
222 uint32_t control_code,
223 uint8_t *control_data,
224 size_t control_data_size,
225 uint8_t *data,
226 size_t data_size,
227 uint32_t *error_code,
228 libcerror_error_t **error );
229
230 LIBCFILE_EXTERN \
231 ssize_t libcfile_file_io_control_read(
232 libcfile_file_t *file,
233 uint32_t control_code,
234 uint8_t *control_data,
235 size_t control_data_size,
236 uint8_t *data,
237 size_t data_size,
238 libcerror_error_t **error );
239
240 LIBCFILE_EXTERN \
241 ssize_t libcfile_file_io_control_read_with_error_code(
242 libcfile_file_t *file,
243 uint32_t control_code,
244 uint8_t *control_data,
245 size_t control_data_size,
246 uint8_t *data,
247 size_t data_size,
248 uint32_t *error_code,
249 libcerror_error_t **error );
250
251 LIBCFILE_EXTERN \
252 int libcfile_file_set_access_behavior(
253 libcfile_file_t *file,
254 int access_behavior,
255 libcerror_error_t **error );
256
257 int libcfile_internal_file_set_block_size(
258 libcfile_internal_file_t *internal_file,
259 size_t block_size,
260 libcerror_error_t **error );
261
262 LIBCFILE_EXTERN \
263 int libcfile_file_set_block_size(
264 libcfile_file_t *file,
265 size_t block_size,
266 libcerror_error_t **error );
267
268 #if defined( __cplusplus )
269 }
270 #endif
271
272 #endif /* !defined( _LIBCFILE_FILE_H ) */
273