/src/libfshfs/libfshfs/libfshfs_directory_entry.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Directory entry functions |
3 | | * |
4 | | * Copyright (C) 2009-2024, Joachim Metz <joachim.metz@gmail.com> |
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 | | #include <common.h> |
23 | | #include <memory.h> |
24 | | #include <types.h> |
25 | | |
26 | | #include "libfshfs_definitions.h" |
27 | | #include "libfshfs_directory_entry.h" |
28 | | #include "libfshfs_directory_record.h" |
29 | | #include "libfshfs_file_record.h" |
30 | | #include "libfshfs_fork_descriptor.h" |
31 | | #include "libfshfs_libcerror.h" |
32 | | #include "libfshfs_libuna.h" |
33 | | #include "libfshfs_name.h" |
34 | | |
35 | | /* Creates a directory entry |
36 | | * Make sure the value directory_entry is referencing, is set to NULL |
37 | | * Returns 1 if successful or -1 on error |
38 | | */ |
39 | | int libfshfs_directory_entry_initialize( |
40 | | libfshfs_directory_entry_t **directory_entry, |
41 | | libcerror_error_t **error ) |
42 | 6.42k | { |
43 | 6.42k | static char *function = "libfshfs_directory_entry_initialize"; |
44 | | |
45 | 6.42k | if( directory_entry == NULL ) |
46 | 0 | { |
47 | 0 | libcerror_error_set( |
48 | 0 | error, |
49 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
50 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
51 | 0 | "%s: invalid directory entry.", |
52 | 0 | function ); |
53 | |
|
54 | 0 | return( -1 ); |
55 | 0 | } |
56 | 6.42k | if( *directory_entry != NULL ) |
57 | 0 | { |
58 | 0 | libcerror_error_set( |
59 | 0 | error, |
60 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
61 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
62 | 0 | "%s: invalid directory entry value already set.", |
63 | 0 | function ); |
64 | |
|
65 | 0 | return( -1 ); |
66 | 0 | } |
67 | 6.42k | *directory_entry = memory_allocate_structure( |
68 | 6.42k | libfshfs_directory_entry_t ); |
69 | | |
70 | 6.42k | if( *directory_entry == NULL ) |
71 | 0 | { |
72 | 0 | libcerror_error_set( |
73 | 0 | error, |
74 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
75 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
76 | 0 | "%s: unable to create directory entry.", |
77 | 0 | function ); |
78 | |
|
79 | 0 | goto on_error; |
80 | 0 | } |
81 | 6.42k | if( memory_set( |
82 | 6.42k | *directory_entry, |
83 | 6.42k | 0, |
84 | 6.42k | sizeof( libfshfs_directory_entry_t ) ) == NULL ) |
85 | 0 | { |
86 | 0 | libcerror_error_set( |
87 | 0 | error, |
88 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
89 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
90 | 0 | "%s: unable to clear directory entry.", |
91 | 0 | function ); |
92 | |
|
93 | 0 | goto on_error; |
94 | 0 | } |
95 | 6.42k | return( 1 ); |
96 | | |
97 | 0 | on_error: |
98 | 0 | if( *directory_entry != NULL ) |
99 | 0 | { |
100 | 0 | memory_free( |
101 | 0 | *directory_entry ); |
102 | |
|
103 | 0 | *directory_entry = NULL; |
104 | 0 | } |
105 | 0 | return( -1 ); |
106 | 6.42k | } |
107 | | |
108 | | /* Frees a directory entry |
109 | | * Returns 1 if successful or -1 on error |
110 | | */ |
111 | | int libfshfs_directory_entry_free( |
112 | | libfshfs_directory_entry_t **directory_entry, |
113 | | libcerror_error_t **error ) |
114 | 8.53k | { |
115 | 8.53k | static char *function = "libfshfs_directory_entry_free"; |
116 | 8.53k | int result = 1; |
117 | | |
118 | 8.53k | if( directory_entry == NULL ) |
119 | 0 | { |
120 | 0 | libcerror_error_set( |
121 | 0 | error, |
122 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
123 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
124 | 0 | "%s: invalid directory entry.", |
125 | 0 | function ); |
126 | |
|
127 | 0 | return( -1 ); |
128 | 0 | } |
129 | 8.53k | if( *directory_entry != NULL ) |
130 | 8.38k | { |
131 | 8.38k | if( ( *directory_entry )->name != NULL ) |
132 | 8.37k | { |
133 | 8.37k | memory_free( |
134 | 8.37k | ( *directory_entry )->name ); |
135 | 8.37k | } |
136 | 8.38k | if( ( *directory_entry )->catalog_record != NULL ) |
137 | 8.37k | { |
138 | 8.37k | if( ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
139 | 8.37k | || ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) ) |
140 | 2.60k | { |
141 | 2.60k | if( libfshfs_directory_record_free( |
142 | 2.60k | (libfshfs_directory_record_t **) &( ( *directory_entry )->catalog_record ), |
143 | 2.60k | error ) != 1 ) |
144 | 0 | { |
145 | 0 | libcerror_error_set( |
146 | 0 | error, |
147 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
148 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
149 | 0 | "%s: unable to free catalog directory record.", |
150 | 0 | function ); |
151 | |
|
152 | 0 | result = -1; |
153 | 0 | } |
154 | 2.60k | } |
155 | 5.77k | else if( ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
156 | 5.77k | || ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
157 | 5.77k | { |
158 | 5.77k | if( libfshfs_file_record_free( |
159 | 5.77k | (libfshfs_file_record_t **) &( ( *directory_entry )->catalog_record ), |
160 | 5.77k | error ) != 1 ) |
161 | 0 | { |
162 | 0 | libcerror_error_set( |
163 | 0 | error, |
164 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
165 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
166 | 0 | "%s: unable to free catalog file record.", |
167 | 0 | function ); |
168 | |
|
169 | 0 | result = -1; |
170 | 0 | } |
171 | 5.77k | } |
172 | 8.37k | } |
173 | 8.38k | memory_free( |
174 | 8.38k | *directory_entry ); |
175 | | |
176 | 8.38k | *directory_entry = NULL; |
177 | 8.38k | } |
178 | 8.53k | return( result ); |
179 | 8.53k | } |
180 | | |
181 | | /* Clones the directory entry value |
182 | | * Returns 1 if successful or -1 on error |
183 | | */ |
184 | | int libfshfs_directory_entry_clone( |
185 | | libfshfs_directory_entry_t **destination_directory_entry, |
186 | | libfshfs_directory_entry_t *source_directory_entry, |
187 | | libcerror_error_t **error ) |
188 | 2.10k | { |
189 | 2.10k | static char *function = "libfshfs_directory_entry_clone"; |
190 | | |
191 | 2.10k | if( destination_directory_entry == NULL ) |
192 | 0 | { |
193 | 0 | libcerror_error_set( |
194 | 0 | error, |
195 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
196 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
197 | 0 | "%s: invalid destination directory entry.", |
198 | 0 | function ); |
199 | |
|
200 | 0 | return( -1 ); |
201 | 0 | } |
202 | 2.10k | if( *destination_directory_entry != NULL ) |
203 | 0 | { |
204 | 0 | libcerror_error_set( |
205 | 0 | error, |
206 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
207 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
208 | 0 | "%s: invalid destination directory entry value already set.", |
209 | 0 | function ); |
210 | |
|
211 | 0 | return( -1 ); |
212 | 0 | } |
213 | 2.10k | if( source_directory_entry == NULL ) |
214 | 154 | { |
215 | 154 | *destination_directory_entry = NULL; |
216 | | |
217 | 154 | return( 1 ); |
218 | 154 | } |
219 | 1.95k | *destination_directory_entry = memory_allocate_structure( |
220 | 1.95k | libfshfs_directory_entry_t ); |
221 | | |
222 | 1.95k | if( *destination_directory_entry == NULL ) |
223 | 0 | { |
224 | 0 | libcerror_error_set( |
225 | 0 | error, |
226 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
227 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
228 | 0 | "%s: unable to create destination directory entry.", |
229 | 0 | function ); |
230 | |
|
231 | 0 | goto on_error; |
232 | 0 | } |
233 | 1.95k | if( memory_copy( |
234 | 1.95k | *destination_directory_entry, |
235 | 1.95k | source_directory_entry, |
236 | 1.95k | sizeof( libfshfs_directory_entry_t ) ) == NULL ) |
237 | 0 | { |
238 | 0 | libcerror_error_set( |
239 | 0 | error, |
240 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
241 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
242 | 0 | "%s: unable to copy source to destination directory entry.", |
243 | 0 | function ); |
244 | |
|
245 | 0 | memory_free( |
246 | 0 | *destination_directory_entry ); |
247 | |
|
248 | 0 | *destination_directory_entry = NULL; |
249 | |
|
250 | 0 | return( -1 ); |
251 | 0 | } |
252 | 1.95k | ( *destination_directory_entry )->name = NULL; |
253 | 1.95k | ( *destination_directory_entry )->catalog_record = NULL; |
254 | | |
255 | 1.95k | if( source_directory_entry->name != NULL ) |
256 | 1.95k | { |
257 | 1.95k | ( *destination_directory_entry )->name = (uint8_t *) memory_allocate( |
258 | 1.95k | sizeof( uint8_t ) * source_directory_entry->name_size ); |
259 | | |
260 | 1.95k | if( ( *destination_directory_entry )->name == NULL ) |
261 | 0 | { |
262 | 0 | libcerror_error_set( |
263 | 0 | error, |
264 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
265 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
266 | 0 | "%s: unable to create destination name.", |
267 | 0 | function ); |
268 | |
|
269 | 0 | goto on_error; |
270 | 0 | } |
271 | 1.95k | if( memory_copy( |
272 | 1.95k | ( *destination_directory_entry )->name, |
273 | 1.95k | source_directory_entry->name, |
274 | 1.95k | source_directory_entry->name_size ) == NULL ) |
275 | 0 | { |
276 | 0 | libcerror_error_set( |
277 | 0 | error, |
278 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
279 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
280 | 0 | "%s: unable to copy source name to destination.", |
281 | 0 | function ); |
282 | |
|
283 | 0 | goto on_error; |
284 | 0 | } |
285 | 1.95k | } |
286 | 1.95k | if( ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
287 | 1.95k | || ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) ) |
288 | 490 | { |
289 | 490 | if( libfshfs_directory_record_clone( |
290 | 490 | (libfshfs_directory_record_t **) &( ( *destination_directory_entry )->catalog_record ), |
291 | 490 | (libfshfs_directory_record_t *) source_directory_entry->catalog_record, |
292 | 490 | error ) != 1 ) |
293 | 0 | { |
294 | 0 | libcerror_error_set( |
295 | 0 | error, |
296 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
297 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
298 | 0 | "%s: unable to create destination catalog directory record.", |
299 | 0 | function ); |
300 | |
|
301 | 0 | goto on_error; |
302 | 0 | } |
303 | 490 | } |
304 | 1.46k | else if( ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
305 | 1.46k | || ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
306 | 1.46k | { |
307 | 1.46k | if( libfshfs_file_record_clone( |
308 | 1.46k | (libfshfs_file_record_t **) &( ( *destination_directory_entry )->catalog_record ), |
309 | 1.46k | (libfshfs_file_record_t *) source_directory_entry->catalog_record, |
310 | 1.46k | error ) != 1 ) |
311 | 0 | { |
312 | 0 | libcerror_error_set( |
313 | 0 | error, |
314 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
315 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
316 | 0 | "%s: unable to create destination catalog file record.", |
317 | 0 | function ); |
318 | |
|
319 | 0 | goto on_error; |
320 | 0 | } |
321 | 1.46k | } |
322 | 1.95k | return( 1 ); |
323 | | |
324 | 0 | on_error: |
325 | 0 | if( *destination_directory_entry != NULL ) |
326 | 0 | { |
327 | 0 | if( ( *destination_directory_entry )->name != NULL ) |
328 | 0 | { |
329 | 0 | memory_free( |
330 | 0 | ( *destination_directory_entry )->name ); |
331 | 0 | } |
332 | 0 | memory_free( |
333 | 0 | *destination_directory_entry ); |
334 | |
|
335 | 0 | *destination_directory_entry = NULL; |
336 | 0 | } |
337 | 0 | return( -1 ); |
338 | 1.95k | } |
339 | | |
340 | | /* Sets the name |
341 | | * Returns 1 if successful or -1 on error |
342 | | */ |
343 | | int libfshfs_directory_entry_set_name( |
344 | | libfshfs_directory_entry_t *directory_entry, |
345 | | const uint8_t *name, |
346 | | size_t name_size, |
347 | | int codepage, |
348 | | libcerror_error_t **error ) |
349 | 6.42k | { |
350 | 6.42k | static char *function = "libfshfs_directory_entry_set_name"; |
351 | | |
352 | 6.42k | if( directory_entry == NULL ) |
353 | 0 | { |
354 | 0 | libcerror_error_set( |
355 | 0 | error, |
356 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
357 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
358 | 0 | "%s: invalid directory entry.", |
359 | 0 | function ); |
360 | |
|
361 | 0 | return( -1 ); |
362 | 0 | } |
363 | 6.42k | if( directory_entry->name != NULL ) |
364 | 0 | { |
365 | 0 | libcerror_error_set( |
366 | 0 | error, |
367 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
368 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
369 | 0 | "%s: invalid directory entry - name value already set.", |
370 | 0 | function ); |
371 | |
|
372 | 0 | return( -1 ); |
373 | 0 | } |
374 | 6.42k | if( name == NULL ) |
375 | 2 | { |
376 | 2 | libcerror_error_set( |
377 | 2 | error, |
378 | 2 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
379 | 2 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
380 | 2 | "%s: invalid name.", |
381 | 2 | function ); |
382 | | |
383 | 2 | return( -1 ); |
384 | 2 | } |
385 | 6.42k | if( name_size > (uint32_t) MEMORY_MAXIMUM_ALLOCATION_SIZE ) |
386 | 0 | { |
387 | 0 | libcerror_error_set( |
388 | 0 | error, |
389 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
390 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, |
391 | 0 | "%s: invalid name size value out of bounds.", |
392 | 0 | function ); |
393 | |
|
394 | 0 | return( -1 ); |
395 | 0 | } |
396 | 6.42k | if( ( codepage != LIBUNA_CODEPAGE_ASCII ) |
397 | 6.42k | && ( codepage != LIBUNA_CODEPAGE_UTF16_BIG_ENDIAN ) ) |
398 | 0 | { |
399 | 0 | libcerror_error_set( |
400 | 0 | error, |
401 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
402 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
403 | 0 | "%s: unsupported codepage.", |
404 | 0 | function ); |
405 | |
|
406 | 0 | return( -1 ); |
407 | 0 | } |
408 | 6.42k | if( name_size > 0 ) |
409 | 6.42k | { |
410 | 6.42k | directory_entry->name = (uint8_t *) memory_allocate( |
411 | 6.42k | sizeof( uint8_t ) * name_size ); |
412 | | |
413 | 6.42k | if( directory_entry->name == NULL ) |
414 | 0 | { |
415 | 0 | libcerror_error_set( |
416 | 0 | error, |
417 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
418 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
419 | 0 | "%s: unable to create name.", |
420 | 0 | function ); |
421 | |
|
422 | 0 | goto on_error; |
423 | 0 | } |
424 | 6.42k | if( memory_copy( |
425 | 6.42k | directory_entry->name, |
426 | 6.42k | name, |
427 | 6.42k | name_size ) == NULL ) |
428 | 0 | { |
429 | 0 | libcerror_error_set( |
430 | 0 | error, |
431 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
432 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
433 | 0 | "%s: unable to copy name.", |
434 | 0 | function ); |
435 | |
|
436 | 0 | goto on_error; |
437 | 0 | } |
438 | 6.42k | } |
439 | 6.42k | directory_entry->name_size = name_size; |
440 | 6.42k | directory_entry->codepage = codepage; |
441 | | |
442 | 6.42k | return( 1 ); |
443 | | |
444 | 0 | on_error: |
445 | 0 | if( directory_entry->name != NULL ) |
446 | 0 | { |
447 | 0 | memory_free( |
448 | 0 | directory_entry->name ); |
449 | |
|
450 | 0 | directory_entry->name = NULL; |
451 | 0 | } |
452 | 0 | directory_entry->name_size = 0; |
453 | |
|
454 | 0 | return( -1 ); |
455 | 6.42k | } |
456 | | |
457 | | /* Sets the catalog record |
458 | | * Returns 1 if successful or -1 on error |
459 | | */ |
460 | | int libfshfs_directory_entry_set_catalog_record( |
461 | | libfshfs_directory_entry_t *directory_entry, |
462 | | uint16_t record_type, |
463 | | intptr_t *catalog_record, |
464 | | libcerror_error_t **error ) |
465 | 6.42k | { |
466 | 6.42k | static char *function = "libfshfs_directory_entry_set_catalog_record"; |
467 | | |
468 | 6.42k | if( directory_entry == NULL ) |
469 | 0 | { |
470 | 0 | libcerror_error_set( |
471 | 0 | error, |
472 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
473 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
474 | 0 | "%s: invalid directory entry.", |
475 | 0 | function ); |
476 | |
|
477 | 0 | return( -1 ); |
478 | 0 | } |
479 | 6.42k | if( directory_entry->catalog_record != NULL ) |
480 | 0 | { |
481 | 0 | libcerror_error_set( |
482 | 0 | error, |
483 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
484 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
485 | 0 | "%s: invalid directory entry - catalog record value already set.", |
486 | 0 | function ); |
487 | |
|
488 | 0 | return( -1 ); |
489 | 0 | } |
490 | 6.42k | if( ( record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
491 | 6.42k | && ( record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
492 | 6.42k | && ( record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
493 | 6.42k | && ( record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
494 | 0 | { |
495 | 0 | libcerror_error_set( |
496 | 0 | error, |
497 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
498 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
499 | 0 | "%s: unsupported record type.", |
500 | 0 | function ); |
501 | |
|
502 | 0 | return( -1 ); |
503 | 0 | } |
504 | 6.42k | if( catalog_record == NULL ) |
505 | 0 | { |
506 | 0 | libcerror_error_set( |
507 | 0 | error, |
508 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
509 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
510 | 0 | "%s: invalid catalog record.", |
511 | 0 | function ); |
512 | |
|
513 | 0 | return( -1 ); |
514 | 0 | } |
515 | 6.42k | directory_entry->record_type = record_type; |
516 | 6.42k | directory_entry->catalog_record = catalog_record; |
517 | | |
518 | 6.42k | return( 1 ); |
519 | 6.42k | } |
520 | | |
521 | | /* Retrieves the flags |
522 | | * Returns 1 if successful or -1 on error |
523 | | */ |
524 | | int libfshfs_directory_entry_get_flags( |
525 | | libfshfs_directory_entry_t *directory_entry, |
526 | | uint16_t *flags, |
527 | | libcerror_error_t **error ) |
528 | 1.05k | { |
529 | 1.05k | static char *function = "libfshfs_directory_entry_get_flags"; |
530 | 1.05k | int result = 0; |
531 | | |
532 | 1.05k | if( directory_entry == NULL ) |
533 | 0 | { |
534 | 0 | libcerror_error_set( |
535 | 0 | error, |
536 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
537 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
538 | 0 | "%s: invalid directory entry.", |
539 | 0 | function ); |
540 | |
|
541 | 0 | return( -1 ); |
542 | 0 | } |
543 | 1.05k | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
544 | 1.05k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
545 | 1.05k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
546 | 1.05k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
547 | 0 | { |
548 | 0 | libcerror_error_set( |
549 | 0 | error, |
550 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
551 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
552 | 0 | "%s: invalid directory entry - unsupported record type.", |
553 | 0 | function ); |
554 | |
|
555 | 0 | return( -1 ); |
556 | 0 | } |
557 | 1.05k | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
558 | 1.05k | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) ) |
559 | 9 | { |
560 | 9 | result = libfshfs_directory_record_get_flags( |
561 | 9 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
562 | 9 | flags, |
563 | 9 | error ); |
564 | 9 | } |
565 | 1.04k | else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
566 | 1.04k | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
567 | 1.04k | { |
568 | 1.04k | result = libfshfs_file_record_get_flags( |
569 | 1.04k | (libfshfs_file_record_t *) directory_entry->catalog_record, |
570 | 1.04k | flags, |
571 | 1.04k | error ); |
572 | 1.04k | } |
573 | 1.05k | if( result != 1 ) |
574 | 0 | { |
575 | 0 | libcerror_error_set( |
576 | 0 | error, |
577 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
578 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
579 | 0 | "%s: unable to retrieve flags from catalog record.", |
580 | 0 | function ); |
581 | |
|
582 | 0 | return( -1 ); |
583 | 0 | } |
584 | 1.05k | return( 1 ); |
585 | 1.05k | } |
586 | | |
587 | | /* Retrieves the identifier |
588 | | * Returns 1 if successful or -1 on error |
589 | | */ |
590 | | int libfshfs_directory_entry_get_identifier( |
591 | | libfshfs_directory_entry_t *directory_entry, |
592 | | uint32_t *identifier, |
593 | | libcerror_error_t **error ) |
594 | 3.03k | { |
595 | 3.03k | static char *function = "libfshfs_directory_entry_get_identifier"; |
596 | 3.03k | int result = 0; |
597 | | |
598 | 3.03k | if( directory_entry == NULL ) |
599 | 0 | { |
600 | 0 | libcerror_error_set( |
601 | 0 | error, |
602 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
603 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
604 | 0 | "%s: invalid directory entry.", |
605 | 0 | function ); |
606 | |
|
607 | 0 | return( -1 ); |
608 | 0 | } |
609 | 3.03k | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
610 | 3.03k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
611 | 3.03k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
612 | 3.03k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
613 | 0 | { |
614 | 0 | libcerror_error_set( |
615 | 0 | error, |
616 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
617 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
618 | 0 | "%s: invalid directory entry - unsupported record type.", |
619 | 0 | function ); |
620 | |
|
621 | 0 | return( -1 ); |
622 | 0 | } |
623 | 3.03k | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
624 | 3.03k | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) ) |
625 | 882 | { |
626 | 882 | result = libfshfs_directory_record_get_identifier( |
627 | 882 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
628 | 882 | identifier, |
629 | 882 | error ); |
630 | 882 | } |
631 | 2.14k | else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
632 | 2.14k | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
633 | 2.14k | { |
634 | 2.14k | result = libfshfs_file_record_get_identifier( |
635 | 2.14k | (libfshfs_file_record_t *) directory_entry->catalog_record, |
636 | 2.14k | identifier, |
637 | 2.14k | error ); |
638 | 2.14k | } |
639 | 3.03k | if( result != 1 ) |
640 | 0 | { |
641 | 0 | libcerror_error_set( |
642 | 0 | error, |
643 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
644 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
645 | 0 | "%s: unable to retrieve identifier from catalog record.", |
646 | 0 | function ); |
647 | |
|
648 | 0 | return( -1 ); |
649 | 0 | } |
650 | 3.03k | return( 1 ); |
651 | 3.03k | } |
652 | | |
653 | | /* Retrieves the parent identifier |
654 | | * Returns 1 if successful or -1 on error |
655 | | */ |
656 | | int libfshfs_directory_entry_get_parent_identifier( |
657 | | libfshfs_directory_entry_t *directory_entry, |
658 | | uint32_t *parent_identifier, |
659 | | libcerror_error_t **error ) |
660 | 2.29k | { |
661 | 2.29k | static char *function = "libfshfs_directory_entry_get_parent_identifier"; |
662 | | |
663 | 2.29k | if( directory_entry == NULL ) |
664 | 0 | { |
665 | 0 | libcerror_error_set( |
666 | 0 | error, |
667 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
668 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
669 | 0 | "%s: invalid directory entry.", |
670 | 0 | function ); |
671 | |
|
672 | 0 | return( -1 ); |
673 | 0 | } |
674 | 2.29k | if( parent_identifier == NULL ) |
675 | 0 | { |
676 | 0 | libcerror_error_set( |
677 | 0 | error, |
678 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
679 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
680 | 0 | "%s: invalid parent identifier.", |
681 | 0 | function ); |
682 | |
|
683 | 0 | return( -1 ); |
684 | 0 | } |
685 | 2.29k | *parent_identifier = directory_entry->parent_identifier; |
686 | | |
687 | 2.29k | return( 1 ); |
688 | 2.29k | } |
689 | | |
690 | | /* Retrieves the creation date and time |
691 | | * The timestamp is a unsigned 32-bit HFS date and time value in number of seconds |
692 | | * Returns 1 if successful or -1 on error |
693 | | */ |
694 | | int libfshfs_directory_entry_get_creation_time( |
695 | | libfshfs_directory_entry_t *directory_entry, |
696 | | uint32_t *hfs_time, |
697 | | libcerror_error_t **error ) |
698 | 789 | { |
699 | 789 | static char *function = "libfshfs_directory_entry_get_creation_time"; |
700 | 789 | int result = 0; |
701 | | |
702 | 789 | if( directory_entry == NULL ) |
703 | 0 | { |
704 | 0 | libcerror_error_set( |
705 | 0 | error, |
706 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
707 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
708 | 0 | "%s: invalid directory entry.", |
709 | 0 | function ); |
710 | |
|
711 | 0 | return( -1 ); |
712 | 0 | } |
713 | 789 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
714 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
715 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
716 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
717 | 0 | { |
718 | 0 | libcerror_error_set( |
719 | 0 | error, |
720 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
721 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
722 | 0 | "%s: invalid directory entry - unsupported record type.", |
723 | 0 | function ); |
724 | |
|
725 | 0 | return( -1 ); |
726 | 0 | } |
727 | 789 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
728 | 789 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) ) |
729 | 24 | { |
730 | 24 | result = libfshfs_directory_record_get_creation_time( |
731 | 24 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
732 | 24 | hfs_time, |
733 | 24 | error ); |
734 | 24 | } |
735 | 765 | else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
736 | 765 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
737 | 765 | { |
738 | 765 | result = libfshfs_file_record_get_creation_time( |
739 | 765 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
740 | 765 | hfs_time, |
741 | 765 | error ); |
742 | 765 | } |
743 | 789 | if( result != 1 ) |
744 | 0 | { |
745 | 0 | libcerror_error_set( |
746 | 0 | error, |
747 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
748 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
749 | 0 | "%s: unable to retrieve creation time from catalog record.", |
750 | 0 | function ); |
751 | |
|
752 | 0 | return( -1 ); |
753 | 0 | } |
754 | 789 | return( 1 ); |
755 | 789 | } |
756 | | |
757 | | /* Retrieves the modification date and time |
758 | | * The timestamp is a unsigned 32-bit HFS date and time value in number of seconds |
759 | | * Returns 1 if successful or -1 on error |
760 | | */ |
761 | | int libfshfs_directory_entry_get_modification_time( |
762 | | libfshfs_directory_entry_t *directory_entry, |
763 | | uint32_t *hfs_time, |
764 | | libcerror_error_t **error ) |
765 | 0 | { |
766 | 0 | static char *function = "libfshfs_directory_entry_get_modification_time"; |
767 | 0 | int result = 0; |
768 | |
|
769 | 0 | if( directory_entry == NULL ) |
770 | 0 | { |
771 | 0 | libcerror_error_set( |
772 | 0 | error, |
773 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
774 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
775 | 0 | "%s: invalid directory entry.", |
776 | 0 | function ); |
777 | |
|
778 | 0 | return( -1 ); |
779 | 0 | } |
780 | 0 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
781 | 0 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
782 | 0 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
783 | 0 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
784 | 0 | { |
785 | 0 | libcerror_error_set( |
786 | 0 | error, |
787 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
788 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
789 | 0 | "%s: invalid directory entry - unsupported record type.", |
790 | 0 | function ); |
791 | |
|
792 | 0 | return( -1 ); |
793 | 0 | } |
794 | 0 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
795 | 0 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) ) |
796 | 0 | { |
797 | 0 | result = libfshfs_directory_record_get_modification_time( |
798 | 0 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
799 | 0 | hfs_time, |
800 | 0 | error ); |
801 | 0 | } |
802 | 0 | else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
803 | 0 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
804 | 0 | { |
805 | 0 | result = libfshfs_file_record_get_modification_time( |
806 | 0 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
807 | 0 | hfs_time, |
808 | 0 | error ); |
809 | 0 | } |
810 | 0 | if( result != 1 ) |
811 | 0 | { |
812 | 0 | libcerror_error_set( |
813 | 0 | error, |
814 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
815 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
816 | 0 | "%s: unable to retrieve modification time from catalog record.", |
817 | 0 | function ); |
818 | |
|
819 | 0 | return( -1 ); |
820 | 0 | } |
821 | 0 | return( 1 ); |
822 | 0 | } |
823 | | |
824 | | /* Retrieves the entry modification date and time |
825 | | * The timestamp is a unsigned 32-bit HFS date and time value in number of seconds |
826 | | * Returns 1 if successful, 0 if not available or -1 on error |
827 | | */ |
828 | | int libfshfs_directory_entry_get_entry_modification_time( |
829 | | libfshfs_directory_entry_t *directory_entry, |
830 | | uint32_t *hfs_time, |
831 | | libcerror_error_t **error ) |
832 | 0 | { |
833 | 0 | static char *function = "libfshfs_directory_entry_get_entry_modification_time"; |
834 | 0 | int result = 0; |
835 | |
|
836 | 0 | if( directory_entry == NULL ) |
837 | 0 | { |
838 | 0 | libcerror_error_set( |
839 | 0 | error, |
840 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
841 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
842 | 0 | "%s: invalid directory entry.", |
843 | 0 | function ); |
844 | |
|
845 | 0 | return( -1 ); |
846 | 0 | } |
847 | 0 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
848 | 0 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
849 | 0 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
850 | 0 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
851 | 0 | { |
852 | 0 | libcerror_error_set( |
853 | 0 | error, |
854 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
855 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
856 | 0 | "%s: invalid directory entry - unsupported record type.", |
857 | 0 | function ); |
858 | |
|
859 | 0 | return( -1 ); |
860 | 0 | } |
861 | 0 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
862 | 0 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) ) |
863 | 0 | { |
864 | 0 | if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
865 | 0 | { |
866 | 0 | result = libfshfs_directory_record_get_entry_modification_time( |
867 | 0 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
868 | 0 | hfs_time, |
869 | 0 | error ); |
870 | 0 | } |
871 | 0 | else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
872 | 0 | { |
873 | 0 | result = libfshfs_file_record_get_entry_modification_time( |
874 | 0 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
875 | 0 | hfs_time, |
876 | 0 | error ); |
877 | 0 | } |
878 | 0 | if( result != 1 ) |
879 | 0 | { |
880 | 0 | libcerror_error_set( |
881 | 0 | error, |
882 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
883 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
884 | 0 | "%s: unable to retrieve entry modification time from catalog record.", |
885 | 0 | function ); |
886 | |
|
887 | 0 | return( -1 ); |
888 | 0 | } |
889 | 0 | } |
890 | 0 | return( result ); |
891 | 0 | } |
892 | | |
893 | | /* Retrieves the access date and time |
894 | | * The timestamp is a unsigned 32-bit HFS date and time value in number of seconds |
895 | | * Returns 1 if successful, 0 if not available or -1 on error |
896 | | */ |
897 | | int libfshfs_directory_entry_get_access_time( |
898 | | libfshfs_directory_entry_t *directory_entry, |
899 | | uint32_t *hfs_time, |
900 | | libcerror_error_t **error ) |
901 | 789 | { |
902 | 789 | static char *function = "libfshfs_directory_entry_get_access_time"; |
903 | 789 | int result = 0; |
904 | | |
905 | 789 | if( directory_entry == NULL ) |
906 | 0 | { |
907 | 0 | libcerror_error_set( |
908 | 0 | error, |
909 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
910 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
911 | 0 | "%s: invalid directory entry.", |
912 | 0 | function ); |
913 | |
|
914 | 0 | return( -1 ); |
915 | 0 | } |
916 | 789 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
917 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
918 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
919 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
920 | 0 | { |
921 | 0 | libcerror_error_set( |
922 | 0 | error, |
923 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
924 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
925 | 0 | "%s: invalid directory entry - unsupported record type.", |
926 | 0 | function ); |
927 | |
|
928 | 0 | return( -1 ); |
929 | 0 | } |
930 | 789 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
931 | 789 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) ) |
932 | 505 | { |
933 | 505 | if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
934 | 15 | { |
935 | 15 | result = libfshfs_directory_record_get_access_time( |
936 | 15 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
937 | 15 | hfs_time, |
938 | 15 | error ); |
939 | 15 | } |
940 | 490 | else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
941 | 490 | { |
942 | 490 | result = libfshfs_file_record_get_access_time( |
943 | 490 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
944 | 490 | hfs_time, |
945 | 490 | error ); |
946 | 490 | } |
947 | 505 | if( result != 1 ) |
948 | 0 | { |
949 | 0 | libcerror_error_set( |
950 | 0 | error, |
951 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
952 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
953 | 0 | "%s: unable to retrieve access time from catalog record.", |
954 | 0 | function ); |
955 | |
|
956 | 0 | return( -1 ); |
957 | 0 | } |
958 | 505 | } |
959 | 789 | return( result ); |
960 | 789 | } |
961 | | |
962 | | /* Retrieves the backup date and time |
963 | | * The timestamp is a unsigned 32-bit HFS date and time value in number of seconds |
964 | | * Returns 1 if successful or -1 on error |
965 | | */ |
966 | | int libfshfs_directory_entry_get_backup_time( |
967 | | libfshfs_directory_entry_t *directory_entry, |
968 | | uint32_t *hfs_time, |
969 | | libcerror_error_t **error ) |
970 | 789 | { |
971 | 789 | static char *function = "libfshfs_directory_entry_get_backup_time"; |
972 | 789 | int result = 0; |
973 | | |
974 | 789 | if( directory_entry == NULL ) |
975 | 0 | { |
976 | 0 | libcerror_error_set( |
977 | 0 | error, |
978 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
979 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
980 | 0 | "%s: invalid directory entry.", |
981 | 0 | function ); |
982 | |
|
983 | 0 | return( -1 ); |
984 | 0 | } |
985 | 789 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
986 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
987 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
988 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
989 | 0 | { |
990 | 0 | libcerror_error_set( |
991 | 0 | error, |
992 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
993 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
994 | 0 | "%s: invalid directory entry - unsupported record type.", |
995 | 0 | function ); |
996 | |
|
997 | 0 | return( -1 ); |
998 | 0 | } |
999 | 789 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1000 | 789 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) ) |
1001 | 24 | { |
1002 | 24 | result = libfshfs_directory_record_get_backup_time( |
1003 | 24 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
1004 | 24 | hfs_time, |
1005 | 24 | error ); |
1006 | 24 | } |
1007 | 765 | else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1008 | 765 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1009 | 765 | { |
1010 | 765 | result = libfshfs_file_record_get_backup_time( |
1011 | 765 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1012 | 765 | hfs_time, |
1013 | 765 | error ); |
1014 | 765 | } |
1015 | 789 | if( result != 1 ) |
1016 | 0 | { |
1017 | 0 | libcerror_error_set( |
1018 | 0 | error, |
1019 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1020 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1021 | 0 | "%s: unable to retrieve backup time from catalog record.", |
1022 | 0 | function ); |
1023 | |
|
1024 | 0 | return( -1 ); |
1025 | 0 | } |
1026 | 789 | return( 1 ); |
1027 | 789 | } |
1028 | | |
1029 | | /* Retrieves the added date and time |
1030 | | * The timestamp is a signed 32-bit POSIX date and time value in number of seconds |
1031 | | * Returns 1 if successful, 0 if not available or -1 on error |
1032 | | */ |
1033 | | int libfshfs_directory_entry_get_added_time( |
1034 | | libfshfs_directory_entry_t *directory_entry, |
1035 | | int32_t *posix_time, |
1036 | | libcerror_error_t **error ) |
1037 | 789 | { |
1038 | 789 | static char *function = "libfshfs_directory_entry_get_added_time"; |
1039 | 789 | int result = 0; |
1040 | | |
1041 | 789 | if( directory_entry == NULL ) |
1042 | 0 | { |
1043 | 0 | libcerror_error_set( |
1044 | 0 | error, |
1045 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1046 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1047 | 0 | "%s: invalid directory entry.", |
1048 | 0 | function ); |
1049 | |
|
1050 | 0 | return( -1 ); |
1051 | 0 | } |
1052 | 789 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1053 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1054 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1055 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1056 | 0 | { |
1057 | 0 | libcerror_error_set( |
1058 | 0 | error, |
1059 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1060 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1061 | 0 | "%s: invalid directory entry - unsupported record type.", |
1062 | 0 | function ); |
1063 | |
|
1064 | 0 | return( -1 ); |
1065 | 0 | } |
1066 | 789 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1067 | 789 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) ) |
1068 | 505 | { |
1069 | 505 | if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1070 | 15 | { |
1071 | 15 | result = libfshfs_directory_record_get_added_time( |
1072 | 15 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
1073 | 15 | posix_time, |
1074 | 15 | error ); |
1075 | 15 | } |
1076 | 490 | else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1077 | 490 | { |
1078 | 490 | result = libfshfs_file_record_get_added_time( |
1079 | 490 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1080 | 490 | posix_time, |
1081 | 490 | error ); |
1082 | 490 | } |
1083 | 505 | if( result == -1 ) |
1084 | 0 | { |
1085 | 0 | libcerror_error_set( |
1086 | 0 | error, |
1087 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1088 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1089 | 0 | "%s: unable to retrieve added time from catalog record.", |
1090 | 0 | function ); |
1091 | |
|
1092 | 0 | return( -1 ); |
1093 | 0 | } |
1094 | 505 | } |
1095 | 789 | return( result ); |
1096 | 789 | } |
1097 | | |
1098 | | /* Retrieves the file mode |
1099 | | * Returns 1 if successful, 0 if not available or -1 on error |
1100 | | */ |
1101 | | int libfshfs_directory_entry_get_file_mode( |
1102 | | libfshfs_directory_entry_t *directory_entry, |
1103 | | uint16_t *file_mode, |
1104 | | libcerror_error_t **error ) |
1105 | 2.58k | { |
1106 | 2.58k | static char *function = "libfshfs_directory_entry_get_file_mode"; |
1107 | 2.58k | int result = 0; |
1108 | | |
1109 | 2.58k | if( directory_entry == NULL ) |
1110 | 0 | { |
1111 | 0 | libcerror_error_set( |
1112 | 0 | error, |
1113 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1114 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1115 | 0 | "%s: invalid directory entry.", |
1116 | 0 | function ); |
1117 | |
|
1118 | 0 | return( -1 ); |
1119 | 0 | } |
1120 | 2.58k | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1121 | 2.58k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1122 | 2.58k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1123 | 2.58k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1124 | 0 | { |
1125 | 0 | libcerror_error_set( |
1126 | 0 | error, |
1127 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1128 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1129 | 0 | "%s: invalid directory entry - unsupported record type.", |
1130 | 0 | function ); |
1131 | |
|
1132 | 0 | return( -1 ); |
1133 | 0 | } |
1134 | 2.58k | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1135 | 2.58k | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) ) |
1136 | 2.30k | { |
1137 | 2.30k | if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1138 | 481 | { |
1139 | 481 | result = libfshfs_directory_record_get_file_mode( |
1140 | 481 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
1141 | 481 | file_mode, |
1142 | 481 | error ); |
1143 | 481 | } |
1144 | 1.82k | else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1145 | 1.82k | { |
1146 | 1.82k | result = libfshfs_file_record_get_file_mode( |
1147 | 1.82k | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1148 | 1.82k | file_mode, |
1149 | 1.82k | error ); |
1150 | 1.82k | } |
1151 | 2.30k | if( result != 1 ) |
1152 | 0 | { |
1153 | 0 | libcerror_error_set( |
1154 | 0 | error, |
1155 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1156 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1157 | 0 | "%s: unable to retrieve file mode from catalog record.", |
1158 | 0 | function ); |
1159 | |
|
1160 | 0 | return( -1 ); |
1161 | 0 | } |
1162 | 2.30k | } |
1163 | 2.58k | return( result ); |
1164 | 2.58k | } |
1165 | | |
1166 | | /* Retrieves the owner identifier |
1167 | | * Returns 1 if successful, 0 if not available or -1 on error |
1168 | | */ |
1169 | | int libfshfs_directory_entry_get_owner_identifier( |
1170 | | libfshfs_directory_entry_t *directory_entry, |
1171 | | uint32_t *owner_identifier, |
1172 | | libcerror_error_t **error ) |
1173 | 789 | { |
1174 | 789 | static char *function = "libfshfs_directory_entry_get_owner_identifier"; |
1175 | 789 | int result = 0; |
1176 | | |
1177 | 789 | if( directory_entry == NULL ) |
1178 | 0 | { |
1179 | 0 | libcerror_error_set( |
1180 | 0 | error, |
1181 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1182 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1183 | 0 | "%s: invalid directory entry.", |
1184 | 0 | function ); |
1185 | |
|
1186 | 0 | return( -1 ); |
1187 | 0 | } |
1188 | 789 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1189 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1190 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1191 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1192 | 0 | { |
1193 | 0 | libcerror_error_set( |
1194 | 0 | error, |
1195 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1196 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1197 | 0 | "%s: invalid directory entry - unsupported record type.", |
1198 | 0 | function ); |
1199 | |
|
1200 | 0 | return( -1 ); |
1201 | 0 | } |
1202 | 789 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1203 | 789 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) ) |
1204 | 505 | { |
1205 | 505 | if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1206 | 15 | { |
1207 | 15 | result = libfshfs_directory_record_get_owner_identifier( |
1208 | 15 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
1209 | 15 | owner_identifier, |
1210 | 15 | error ); |
1211 | 15 | } |
1212 | 490 | else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1213 | 490 | { |
1214 | 490 | result = libfshfs_file_record_get_owner_identifier( |
1215 | 490 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1216 | 490 | owner_identifier, |
1217 | 490 | error ); |
1218 | 490 | } |
1219 | 505 | if( result != 1 ) |
1220 | 0 | { |
1221 | 0 | libcerror_error_set( |
1222 | 0 | error, |
1223 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1224 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1225 | 0 | "%s: unable to retrieve owner identifier from catalog record.", |
1226 | 0 | function ); |
1227 | |
|
1228 | 0 | return( -1 ); |
1229 | 0 | } |
1230 | 505 | } |
1231 | 789 | return( result ); |
1232 | 789 | } |
1233 | | |
1234 | | /* Retrieves the group identifier |
1235 | | * Returns 1 if successful, 0 if not available or -1 on error |
1236 | | */ |
1237 | | int libfshfs_directory_entry_get_group_identifier( |
1238 | | libfshfs_directory_entry_t *directory_entry, |
1239 | | uint32_t *group_identifier, |
1240 | | libcerror_error_t **error ) |
1241 | 789 | { |
1242 | 789 | static char *function = "libfshfs_directory_entry_get_group_identifier"; |
1243 | 789 | int result = 0; |
1244 | | |
1245 | 789 | if( directory_entry == NULL ) |
1246 | 0 | { |
1247 | 0 | libcerror_error_set( |
1248 | 0 | error, |
1249 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1250 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1251 | 0 | "%s: invalid directory entry.", |
1252 | 0 | function ); |
1253 | |
|
1254 | 0 | return( -1 ); |
1255 | 0 | } |
1256 | 789 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1257 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1258 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1259 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1260 | 0 | { |
1261 | 0 | libcerror_error_set( |
1262 | 0 | error, |
1263 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1264 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1265 | 0 | "%s: invalid directory entry - unsupported record type.", |
1266 | 0 | function ); |
1267 | |
|
1268 | 0 | return( -1 ); |
1269 | 0 | } |
1270 | 789 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1271 | 789 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) ) |
1272 | 505 | { |
1273 | 505 | if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1274 | 15 | { |
1275 | 15 | result = libfshfs_directory_record_get_group_identifier( |
1276 | 15 | (libfshfs_directory_record_t *) directory_entry->catalog_record, |
1277 | 15 | group_identifier, |
1278 | 15 | error ); |
1279 | 15 | } |
1280 | 490 | else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1281 | 490 | { |
1282 | 490 | result = libfshfs_file_record_get_group_identifier( |
1283 | 490 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1284 | 490 | group_identifier, |
1285 | 490 | error ); |
1286 | 490 | } |
1287 | 505 | if( result != 1 ) |
1288 | 0 | { |
1289 | 0 | libcerror_error_set( |
1290 | 0 | error, |
1291 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1292 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1293 | 0 | "%s: unable to retrieve group identifier from catalog record.", |
1294 | 0 | function ); |
1295 | |
|
1296 | 0 | return( -1 ); |
1297 | 0 | } |
1298 | 505 | } |
1299 | 789 | return( result ); |
1300 | 789 | } |
1301 | | |
1302 | | /* Retrieves the special permissions |
1303 | | * Returns 1 if successful, 0 if not available or -1 on error |
1304 | | */ |
1305 | | int libfshfs_directory_entry_get_special_permissions( |
1306 | | libfshfs_directory_entry_t *directory_entry, |
1307 | | uint32_t *special_permissions, |
1308 | | libcerror_error_t **error ) |
1309 | 183 | { |
1310 | 183 | static char *function = "libfshfs_directory_entry_get_special_permissions"; |
1311 | 183 | int result = 0; |
1312 | | |
1313 | 183 | if( directory_entry == NULL ) |
1314 | 0 | { |
1315 | 0 | libcerror_error_set( |
1316 | 0 | error, |
1317 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1318 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1319 | 0 | "%s: invalid directory entry.", |
1320 | 0 | function ); |
1321 | |
|
1322 | 0 | return( -1 ); |
1323 | 0 | } |
1324 | 183 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1325 | 183 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1326 | 183 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1327 | 183 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1328 | 0 | { |
1329 | 0 | libcerror_error_set( |
1330 | 0 | error, |
1331 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1332 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1333 | 0 | "%s: invalid directory entry - unsupported record type.", |
1334 | 0 | function ); |
1335 | |
|
1336 | 0 | return( -1 ); |
1337 | 0 | } |
1338 | 183 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1339 | 183 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1340 | 164 | { |
1341 | 164 | result = libfshfs_file_record_get_special_permissions( |
1342 | 164 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1343 | 164 | special_permissions, |
1344 | 164 | error ); |
1345 | | |
1346 | 164 | if( result == -1 ) |
1347 | 0 | { |
1348 | 0 | libcerror_error_set( |
1349 | 0 | error, |
1350 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1351 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1352 | 0 | "%s: unable to retrieve special permissions from catalog record.", |
1353 | 0 | function ); |
1354 | |
|
1355 | 0 | return( -1 ); |
1356 | 0 | } |
1357 | 164 | } |
1358 | 183 | return( result ); |
1359 | 183 | } |
1360 | | |
1361 | | /* Retrieves the link reference |
1362 | | * Returns 1 if successful, 0 if not available or -1 on error |
1363 | | */ |
1364 | | int libfshfs_directory_entry_get_link_reference( |
1365 | | libfshfs_directory_entry_t *directory_entry, |
1366 | | uint32_t *link_reference, |
1367 | | libcerror_error_t **error ) |
1368 | 2.29k | { |
1369 | 2.29k | static char *function = "libfshfs_directory_entry_get_link_reference"; |
1370 | 2.29k | int result = 0; |
1371 | | |
1372 | 2.29k | if( directory_entry == NULL ) |
1373 | 0 | { |
1374 | 0 | libcerror_error_set( |
1375 | 0 | error, |
1376 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1377 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1378 | 0 | "%s: invalid directory entry.", |
1379 | 0 | function ); |
1380 | |
|
1381 | 0 | return( -1 ); |
1382 | 0 | } |
1383 | 2.29k | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1384 | 2.29k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1385 | 2.29k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1386 | 2.29k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1387 | 0 | { |
1388 | 0 | libcerror_error_set( |
1389 | 0 | error, |
1390 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1391 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1392 | 0 | "%s: invalid directory entry - unsupported record type.", |
1393 | 0 | function ); |
1394 | |
|
1395 | 0 | return( -1 ); |
1396 | 0 | } |
1397 | 2.29k | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1398 | 2.29k | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1399 | 1.80k | { |
1400 | 1.80k | result = libfshfs_file_record_get_link_reference( |
1401 | 1.80k | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1402 | 1.80k | link_reference, |
1403 | 1.80k | error ); |
1404 | | |
1405 | 1.80k | if( result == -1 ) |
1406 | 0 | { |
1407 | 0 | libcerror_error_set( |
1408 | 0 | error, |
1409 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1410 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1411 | 0 | "%s: unable to retrieve link reference from catalog record.", |
1412 | 0 | function ); |
1413 | |
|
1414 | 0 | return( -1 ); |
1415 | 0 | } |
1416 | 1.80k | } |
1417 | 2.29k | return( result ); |
1418 | 2.29k | } |
1419 | | |
1420 | | /* Retrieves the size of the UTF-8 encoded name |
1421 | | * The returned size includes the end of string character |
1422 | | * Returns 1 if successful or -1 on error |
1423 | | */ |
1424 | | int libfshfs_directory_entry_get_utf8_name_size( |
1425 | | libfshfs_directory_entry_t *directory_entry, |
1426 | | size_t *utf8_string_size, |
1427 | | libcerror_error_t **error ) |
1428 | 1.07k | { |
1429 | 1.07k | static char *function = "libfshfs_directory_entry_get_utf8_name_size"; |
1430 | | |
1431 | 1.07k | if( directory_entry == NULL ) |
1432 | 0 | { |
1433 | 0 | libcerror_error_set( |
1434 | 0 | error, |
1435 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1436 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1437 | 0 | "%s: invalid directory entry.", |
1438 | 0 | function ); |
1439 | |
|
1440 | 0 | return( -1 ); |
1441 | 0 | } |
1442 | 1.07k | if( libfshfs_name_get_utf8_string_size( |
1443 | 1.07k | directory_entry->name, |
1444 | 1.07k | (size_t) directory_entry->name_size, |
1445 | 1.07k | directory_entry->codepage, |
1446 | 1.07k | utf8_string_size, |
1447 | 1.07k | error ) != 1 ) |
1448 | 463 | { |
1449 | 463 | libcerror_error_set( |
1450 | 463 | error, |
1451 | 463 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1452 | 463 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1453 | 463 | "%s: unable to retrieve UTF-8 string size.", |
1454 | 463 | function ); |
1455 | | |
1456 | 463 | return( -1 ); |
1457 | 463 | } |
1458 | 612 | return( 1 ); |
1459 | 1.07k | } |
1460 | | |
1461 | | /* Retrieves the UTF-8 encoded name |
1462 | | * The size should include the end of string character |
1463 | | * Returns 1 if successful or -1 on error |
1464 | | */ |
1465 | | int libfshfs_directory_entry_get_utf8_name( |
1466 | | libfshfs_directory_entry_t *directory_entry, |
1467 | | uint8_t *utf8_string, |
1468 | | size_t utf8_string_size, |
1469 | | libcerror_error_t **error ) |
1470 | 1.07k | { |
1471 | 1.07k | static char *function = "libfshfs_directory_entry_get_utf8_name"; |
1472 | | |
1473 | 1.07k | if( directory_entry == NULL ) |
1474 | 0 | { |
1475 | 0 | libcerror_error_set( |
1476 | 0 | error, |
1477 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1478 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1479 | 0 | "%s: invalid directory entry.", |
1480 | 0 | function ); |
1481 | |
|
1482 | 0 | return( -1 ); |
1483 | 0 | } |
1484 | 1.07k | if( libfshfs_name_get_utf8_string( |
1485 | 1.07k | directory_entry->name, |
1486 | 1.07k | (size_t) directory_entry->name_size, |
1487 | 1.07k | directory_entry->codepage, |
1488 | 1.07k | utf8_string, |
1489 | 1.07k | utf8_string_size, |
1490 | 1.07k | error ) != 1 ) |
1491 | 729 | { |
1492 | 729 | libcerror_error_set( |
1493 | 729 | error, |
1494 | 729 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1495 | 729 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1496 | 729 | "%s: unable to retrieve UTF-8 string.", |
1497 | 729 | function ); |
1498 | | |
1499 | 729 | return( -1 ); |
1500 | 729 | } |
1501 | 346 | return( 1 ); |
1502 | 1.07k | } |
1503 | | |
1504 | | /* Retrieves the size of the UTF-16 encoded name |
1505 | | * The returned size includes the end of string character |
1506 | | * Returns 1 if successful or -1 on error |
1507 | | */ |
1508 | | int libfshfs_directory_entry_get_utf16_name_size( |
1509 | | libfshfs_directory_entry_t *directory_entry, |
1510 | | size_t *utf16_string_size, |
1511 | | libcerror_error_t **error ) |
1512 | 0 | { |
1513 | 0 | static char *function = "libfshfs_directory_entry_get_utf16_name_size"; |
1514 | |
|
1515 | 0 | if( directory_entry == NULL ) |
1516 | 0 | { |
1517 | 0 | libcerror_error_set( |
1518 | 0 | error, |
1519 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1520 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1521 | 0 | "%s: invalid directory entry.", |
1522 | 0 | function ); |
1523 | |
|
1524 | 0 | return( -1 ); |
1525 | 0 | } |
1526 | 0 | if( libfshfs_name_get_utf16_string_size( |
1527 | 0 | directory_entry->name, |
1528 | 0 | (size_t) directory_entry->name_size, |
1529 | 0 | directory_entry->codepage, |
1530 | 0 | utf16_string_size, |
1531 | 0 | error ) != 1 ) |
1532 | 0 | { |
1533 | 0 | libcerror_error_set( |
1534 | 0 | error, |
1535 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1536 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1537 | 0 | "%s: unable to retrieve UTF-16 string size.", |
1538 | 0 | function ); |
1539 | |
|
1540 | 0 | return( -1 ); |
1541 | 0 | } |
1542 | 0 | return( 1 ); |
1543 | 0 | } |
1544 | | |
1545 | | /* Retrieves the UTF-16 encoded name |
1546 | | * The size should include the end of string character |
1547 | | * Returns 1 if successful or -1 on error |
1548 | | */ |
1549 | | int libfshfs_directory_entry_get_utf16_name( |
1550 | | libfshfs_directory_entry_t *directory_entry, |
1551 | | uint16_t *utf16_string, |
1552 | | size_t utf16_string_size, |
1553 | | libcerror_error_t **error ) |
1554 | 0 | { |
1555 | 0 | static char *function = "libfshfs_directory_entry_get_utf16_name"; |
1556 | |
|
1557 | 0 | if( directory_entry == NULL ) |
1558 | 0 | { |
1559 | 0 | libcerror_error_set( |
1560 | 0 | error, |
1561 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1562 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1563 | 0 | "%s: invalid directory entry.", |
1564 | 0 | function ); |
1565 | |
|
1566 | 0 | return( -1 ); |
1567 | 0 | } |
1568 | 0 | if( libfshfs_name_get_utf16_string( |
1569 | 0 | directory_entry->name, |
1570 | 0 | (size_t) directory_entry->name_size, |
1571 | 0 | directory_entry->codepage, |
1572 | 0 | utf16_string, |
1573 | 0 | utf16_string_size, |
1574 | 0 | error ) != 1 ) |
1575 | 0 | { |
1576 | 0 | libcerror_error_set( |
1577 | 0 | error, |
1578 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1579 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1580 | 0 | "%s: unable to retrieve UTF-16 string.", |
1581 | 0 | function ); |
1582 | |
|
1583 | 0 | return( -1 ); |
1584 | 0 | } |
1585 | 0 | return( 1 ); |
1586 | 0 | } |
1587 | | |
1588 | | /* Retrieves the data fork descriptor |
1589 | | * Returns 1 if successful, 0 if not available or -1 on error |
1590 | | */ |
1591 | | int libfshfs_directory_entry_get_data_fork_descriptor( |
1592 | | libfshfs_directory_entry_t *directory_entry, |
1593 | | libfshfs_fork_descriptor_t **fork_descriptor, |
1594 | | libcerror_error_t **error ) |
1595 | 1.94k | { |
1596 | 1.94k | static char *function = "libfshfs_directory_entry_get_data_fork_descriptor"; |
1597 | 1.94k | int result = 0; |
1598 | | |
1599 | 1.94k | if( directory_entry == NULL ) |
1600 | 0 | { |
1601 | 0 | libcerror_error_set( |
1602 | 0 | error, |
1603 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1604 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1605 | 0 | "%s: invalid directory entry.", |
1606 | 0 | function ); |
1607 | |
|
1608 | 0 | return( -1 ); |
1609 | 0 | } |
1610 | 1.94k | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1611 | 1.94k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1612 | 1.94k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1613 | 1.94k | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1614 | 0 | { |
1615 | 0 | libcerror_error_set( |
1616 | 0 | error, |
1617 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1618 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1619 | 0 | "%s: invalid directory entry - unsupported record type.", |
1620 | 0 | function ); |
1621 | |
|
1622 | 0 | return( -1 ); |
1623 | 0 | } |
1624 | 1.94k | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1625 | 1.94k | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1626 | 1.89k | { |
1627 | 1.89k | result = libfshfs_file_record_get_data_fork_descriptor( |
1628 | 1.89k | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1629 | 1.89k | fork_descriptor, |
1630 | 1.89k | error ); |
1631 | | |
1632 | 1.89k | if( result != 1 ) |
1633 | 0 | { |
1634 | 0 | libcerror_error_set( |
1635 | 0 | error, |
1636 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1637 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1638 | 0 | "%s: unable to retrieve data fork descriptor from catalog record.", |
1639 | 0 | function ); |
1640 | |
|
1641 | 0 | return( -1 ); |
1642 | 0 | } |
1643 | 1.89k | } |
1644 | 1.94k | return( result ); |
1645 | 1.94k | } |
1646 | | |
1647 | | /* Retrieves the resource fork descriptor |
1648 | | * Returns 1 if successful, 0 if not available or -1 on error |
1649 | | */ |
1650 | | int libfshfs_directory_entry_get_resource_fork_descriptor( |
1651 | | libfshfs_directory_entry_t *directory_entry, |
1652 | | libfshfs_fork_descriptor_t **fork_descriptor, |
1653 | | libcerror_error_t **error ) |
1654 | 789 | { |
1655 | 789 | static char *function = "libfshfs_directory_entry_get_resource_fork_descriptor"; |
1656 | 789 | int result = 0; |
1657 | | |
1658 | 789 | if( directory_entry == NULL ) |
1659 | 0 | { |
1660 | 0 | libcerror_error_set( |
1661 | 0 | error, |
1662 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1663 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1664 | 0 | "%s: invalid directory entry.", |
1665 | 0 | function ); |
1666 | |
|
1667 | 0 | return( -1 ); |
1668 | 0 | } |
1669 | 789 | if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD ) |
1670 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1671 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) |
1672 | 789 | && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1673 | 0 | { |
1674 | 0 | libcerror_error_set( |
1675 | 0 | error, |
1676 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1677 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1678 | 0 | "%s: invalid directory entry - unsupported record type.", |
1679 | 0 | function ); |
1680 | |
|
1681 | 0 | return( -1 ); |
1682 | 0 | } |
1683 | 789 | if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) |
1684 | 789 | || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) ) |
1685 | 765 | { |
1686 | 765 | result = libfshfs_file_record_get_resource_fork_descriptor( |
1687 | 765 | (libfshfs_file_record_t *) directory_entry->catalog_record, |
1688 | 765 | fork_descriptor, |
1689 | 765 | error ); |
1690 | | |
1691 | 765 | if( result == -1 ) |
1692 | 0 | { |
1693 | 0 | libcerror_error_set( |
1694 | 0 | error, |
1695 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1696 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1697 | 0 | "%s: unable to retrieve resource fork descriptor from catalog record.", |
1698 | 0 | function ); |
1699 | |
|
1700 | 0 | return( -1 ); |
1701 | 0 | } |
1702 | 765 | } |
1703 | 789 | return( result ); |
1704 | 789 | } |
1705 | | |