Coverage Report

Created: 2026-04-04 07:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libfshfs/libfshfs/libfshfs_directory_entry.c
Line
Count
Source
1
/*
2
 * Directory entry functions
3
 *
4
 * Copyright (C) 2009-2026, 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
7.47k
{
43
7.47k
  static char *function = "libfshfs_directory_entry_initialize";
44
45
7.47k
  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
7.47k
  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
7.47k
  *directory_entry = memory_allocate_structure(
68
7.47k
                      libfshfs_directory_entry_t );
69
70
7.47k
  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
7.47k
  if( memory_set(
82
7.47k
       *directory_entry,
83
7.47k
       0,
84
7.47k
       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
7.47k
  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
7.47k
}
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
10.1k
{
115
10.1k
  static char *function = "libfshfs_directory_entry_free";
116
10.1k
  int result            = 1;
117
118
10.1k
  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
10.1k
  if( *directory_entry != NULL )
130
10.0k
  {
131
10.0k
    if( ( *directory_entry )->name != NULL )
132
10.0k
    {
133
10.0k
      memory_free(
134
10.0k
       ( *directory_entry )->name );
135
10.0k
    }
136
10.0k
    if( ( *directory_entry )->catalog_record != NULL )
137
10.0k
    {
138
10.0k
      if( ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
139
7.38k
       || ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) )
140
3.08k
      {
141
3.08k
        if( libfshfs_directory_record_free(
142
3.08k
             (libfshfs_directory_record_t **) &( ( *directory_entry )->catalog_record ),
143
3.08k
             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
3.08k
      }
155
6.92k
      else if( ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
156
2.48k
            || ( ( *directory_entry )->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
157
6.92k
      {
158
6.92k
        if( libfshfs_file_record_free(
159
6.92k
             (libfshfs_file_record_t **) &( ( *directory_entry )->catalog_record ),
160
6.92k
             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
6.92k
      }
172
10.0k
    }
173
10.0k
    memory_free(
174
10.0k
     *directory_entry );
175
176
10.0k
    *directory_entry = NULL;
177
10.0k
  }
178
10.1k
  return( result );
179
10.1k
}
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.70k
{
189
2.70k
  static char *function = "libfshfs_directory_entry_clone";
190
191
2.70k
  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.70k
  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.70k
  if( source_directory_entry == NULL )
214
178
  {
215
178
    *destination_directory_entry = NULL;
216
217
178
    return( 1 );
218
178
  }
219
2.53k
  *destination_directory_entry = memory_allocate_structure(
220
2.53k
                                  libfshfs_directory_entry_t );
221
222
2.53k
  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
2.53k
  if( memory_copy(
234
2.53k
       *destination_directory_entry,
235
2.53k
       source_directory_entry,
236
2.53k
       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
2.53k
  ( *destination_directory_entry )->name           = NULL;
253
2.53k
  ( *destination_directory_entry )->catalog_record = NULL;
254
255
2.53k
  if( source_directory_entry->name != NULL )
256
2.53k
  {
257
2.53k
    ( *destination_directory_entry )->name = (uint8_t *) memory_allocate(
258
2.53k
                                                          sizeof( uint8_t ) * source_directory_entry->name_size );
259
260
2.53k
    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
2.53k
    if( memory_copy(
272
2.53k
         ( *destination_directory_entry )->name,
273
2.53k
         source_directory_entry->name,
274
2.53k
         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
2.53k
  }
286
2.53k
  if( ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
287
1.87k
   || ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) )
288
689
  {
289
689
    if( libfshfs_directory_record_clone(
290
689
         (libfshfs_directory_record_t **) &( ( *destination_directory_entry )->catalog_record ),
291
689
         (libfshfs_directory_record_t *) source_directory_entry->catalog_record,
292
689
         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
689
  }
304
1.84k
  else if( ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
305
567
        || ( source_directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
306
1.84k
  {
307
1.84k
    if( libfshfs_file_record_clone(
308
1.84k
         (libfshfs_file_record_t **) &( ( *destination_directory_entry )->catalog_record ),
309
1.84k
         (libfshfs_file_record_t *) source_directory_entry->catalog_record,
310
1.84k
         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.84k
  }
322
2.53k
  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
2.53k
}
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
7.47k
{
350
7.47k
  static char *function = "libfshfs_directory_entry_set_name";
351
352
7.47k
  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
7.47k
  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
7.47k
  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
7.47k
  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
7.47k
  if( ( codepage != LIBUNA_CODEPAGE_ASCII )
397
7.47k
   && ( 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
7.47k
  if( name_size > 0 )
409
7.47k
  {
410
7.47k
    directory_entry->name = (uint8_t *) memory_allocate(
411
7.47k
                                         sizeof( uint8_t ) * name_size );
412
413
7.47k
    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
7.47k
    if( memory_copy(
425
7.47k
         directory_entry->name,
426
7.47k
         name,
427
7.47k
         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
7.47k
  }
439
7.47k
  directory_entry->name_size = name_size;
440
7.47k
  directory_entry->codepage  = codepage;
441
442
7.47k
  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
7.47k
}
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
7.47k
{
466
7.47k
  static char *function = "libfshfs_directory_entry_set_catalog_record";
467
468
7.47k
  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
7.47k
  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
7.47k
  if( ( record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
491
5.50k
   && ( record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
492
2.34k
   && ( record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
493
1.91k
   && ( 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
7.47k
  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
7.47k
  directory_entry->record_type    = record_type;
516
7.47k
  directory_entry->catalog_record = catalog_record;
517
518
7.47k
  return( 1 );
519
7.47k
}
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.25k
{
529
1.25k
  static char *function = "libfshfs_directory_entry_get_flags";
530
1.25k
  int result            = 0;
531
532
1.25k
  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.25k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
544
1.24k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
545
346
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
546
343
   && ( 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.25k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
558
1.24k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) )
559
16
  {
560
16
    result = libfshfs_directory_record_get_flags(
561
16
              (libfshfs_directory_record_t *) directory_entry->catalog_record,
562
16
              flags,
563
16
              error );
564
16
  }
565
1.23k
  else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
566
343
        || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
567
1.23k
  {
568
1.23k
    result = libfshfs_file_record_get_flags(
569
1.23k
              (libfshfs_file_record_t *) directory_entry->catalog_record,
570
1.23k
              flags,
571
1.23k
              error );
572
1.23k
  }
573
1.25k
  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.25k
  return( 1 );
585
1.25k
}
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.47k
{
595
3.47k
  static char *function = "libfshfs_directory_entry_get_identifier";
596
3.47k
  int result            = 0;
597
598
3.47k
  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.47k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
610
2.47k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
611
632
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
612
577
   && ( 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.47k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
624
2.47k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) )
625
1.05k
  {
626
1.05k
    result = libfshfs_directory_record_get_identifier(
627
1.05k
              (libfshfs_directory_record_t *) directory_entry->catalog_record,
628
1.05k
              identifier,
629
1.05k
              error );
630
1.05k
  }
631
2.42k
  else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
632
577
        || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
633
2.42k
  {
634
2.42k
    result = libfshfs_file_record_get_identifier(
635
2.42k
              (libfshfs_file_record_t *) directory_entry->catalog_record,
636
2.42k
              identifier,
637
2.42k
              error );
638
2.42k
  }
639
3.47k
  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.47k
  return( 1 );
651
3.47k
}
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.82k
{
661
2.82k
  static char *function = "libfshfs_directory_entry_get_parent_identifier";
662
663
2.82k
  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.82k
  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.82k
  *parent_identifier = directory_entry->parent_identifier;
686
687
2.82k
  return( 1 );
688
2.82k
}
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
1.03k
{
699
1.03k
  static char *function = "libfshfs_directory_entry_get_creation_time";
700
1.03k
  int result            = 0;
701
702
1.03k
  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
1.03k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
714
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
715
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
716
342
   && ( 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
1.03k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
728
1.01k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) )
729
27
  {
730
27
    result = libfshfs_directory_record_get_creation_time(
731
27
              (libfshfs_directory_record_t *) directory_entry->catalog_record,
732
27
              hfs_time,
733
27
              error );
734
27
  }
735
1.01k
  else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
736
342
        || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
737
1.01k
  {
738
1.01k
    result = libfshfs_file_record_get_creation_time(
739
1.01k
              (libfshfs_file_record_t *) directory_entry->catalog_record,
740
1.01k
              hfs_time,
741
1.01k
              error );
742
1.01k
  }
743
1.03k
  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
1.03k
  return( 1 );
755
1.03k
}
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
1.03k
{
902
1.03k
  static char *function = "libfshfs_directory_entry_get_access_time";
903
1.03k
  int result            = 0;
904
905
1.03k
  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
1.03k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
917
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
918
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
919
342
   && ( 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
1.03k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
931
1.01k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) )
932
687
  {
933
687
    if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
934
19
    {
935
19
      result = libfshfs_directory_record_get_access_time(
936
19
          (libfshfs_directory_record_t *) directory_entry->catalog_record,
937
19
          hfs_time,
938
19
          error );
939
19
    }
940
668
    else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
941
668
    {
942
668
      result = libfshfs_file_record_get_access_time(
943
668
          (libfshfs_file_record_t *) directory_entry->catalog_record,
944
668
          hfs_time,
945
668
          error );
946
668
    }
947
687
    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
687
  }
959
1.03k
  return( result );
960
1.03k
}
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
1.03k
{
971
1.03k
  static char *function = "libfshfs_directory_entry_get_backup_time";
972
1.03k
  int result            = 0;
973
974
1.03k
  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
1.03k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
986
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
987
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
988
342
   && ( 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
1.03k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1000
1.01k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD ) )
1001
27
  {
1002
27
    result = libfshfs_directory_record_get_backup_time(
1003
27
              (libfshfs_directory_record_t *) directory_entry->catalog_record,
1004
27
              hfs_time,
1005
27
              error );
1006
27
  }
1007
1.01k
  else if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1008
342
        || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
1009
1.01k
  {
1010
1.01k
    result = libfshfs_file_record_get_backup_time(
1011
1.01k
              (libfshfs_file_record_t *) directory_entry->catalog_record,
1012
1.01k
              hfs_time,
1013
1.01k
              error );
1014
1.01k
  }
1015
1.03k
  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
1.03k
  return( 1 );
1027
1.03k
}
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
1.03k
{
1038
1.03k
  static char *function = "libfshfs_directory_entry_get_added_time";
1039
1.03k
  int result            = 0;
1040
1041
1.03k
  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
1.03k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1053
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1054
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1055
342
   && ( 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
1.03k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1067
1.01k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) )
1068
687
  {
1069
687
    if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1070
19
    {
1071
19
      result = libfshfs_directory_record_get_added_time(
1072
19
          (libfshfs_directory_record_t *) directory_entry->catalog_record,
1073
19
          posix_time,
1074
19
          error );
1075
19
    }
1076
668
    else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1077
668
    {
1078
668
      result = libfshfs_file_record_get_added_time(
1079
668
          (libfshfs_file_record_t *) directory_entry->catalog_record,
1080
668
          posix_time,
1081
668
          error );
1082
668
    }
1083
687
    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
687
  }
1095
1.03k
  return( result );
1096
1.03k
}
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
3.25k
{
1106
3.25k
  static char *function = "libfshfs_directory_entry_get_file_mode";
1107
3.25k
  int result            = 0;
1108
1109
3.25k
  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
3.25k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1121
2.57k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1122
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1123
342
   && ( 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
3.25k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1135
2.57k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) )
1136
2.90k
  {
1137
2.90k
    if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1138
685
    {
1139
685
      result = libfshfs_directory_record_get_file_mode(
1140
685
                (libfshfs_directory_record_t *) directory_entry->catalog_record,
1141
685
                file_mode,
1142
685
                error );
1143
685
    }
1144
2.22k
    else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1145
2.22k
    {
1146
2.22k
      result = libfshfs_file_record_get_file_mode(
1147
2.22k
                (libfshfs_file_record_t *) directory_entry->catalog_record,
1148
2.22k
                file_mode,
1149
2.22k
                error );
1150
2.22k
    }
1151
2.90k
    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.90k
  }
1163
3.25k
  return( result );
1164
3.25k
}
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
1.03k
{
1174
1.03k
  static char *function = "libfshfs_directory_entry_get_owner_identifier";
1175
1.03k
  int result            = 0;
1176
1177
1.03k
  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
1.03k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1189
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1190
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1191
342
   && ( 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
1.03k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1203
1.01k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) )
1204
687
  {
1205
687
    if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1206
19
    {
1207
19
      result = libfshfs_directory_record_get_owner_identifier(
1208
19
                (libfshfs_directory_record_t *) directory_entry->catalog_record,
1209
19
                owner_identifier,
1210
19
                error );
1211
19
    }
1212
668
    else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1213
668
    {
1214
668
      result = libfshfs_file_record_get_owner_identifier(
1215
668
                (libfshfs_file_record_t *) directory_entry->catalog_record,
1216
668
                owner_identifier,
1217
668
                error );
1218
668
    }
1219
687
    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
687
  }
1231
1.03k
  return( result );
1232
1.03k
}
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
1.03k
{
1242
1.03k
  static char *function = "libfshfs_directory_entry_get_group_identifier";
1243
1.03k
  int result            = 0;
1244
1245
1.03k
  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
1.03k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1257
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1258
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1259
342
   && ( 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
1.03k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1271
1.01k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD ) )
1272
687
  {
1273
687
    if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1274
19
    {
1275
19
      result = libfshfs_directory_record_get_group_identifier(
1276
19
                (libfshfs_directory_record_t *) directory_entry->catalog_record,
1277
19
                group_identifier,
1278
19
                error );
1279
19
    }
1280
668
    else if( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1281
668
    {
1282
668
      result = libfshfs_file_record_get_group_identifier(
1283
668
                (libfshfs_file_record_t *) directory_entry->catalog_record,
1284
668
                group_identifier,
1285
668
                error );
1286
668
    }
1287
687
    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
687
  }
1299
1.03k
  return( result );
1300
1.03k
}
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
233
{
1310
233
  static char *function = "libfshfs_directory_entry_get_special_permissions";
1311
233
  int result            = 0;
1312
1313
233
  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
233
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1325
225
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1326
9
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1327
4
   && ( 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
233
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1339
17
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
1340
220
  {
1341
220
    result = libfshfs_file_record_get_special_permissions(
1342
220
              (libfshfs_file_record_t *) directory_entry->catalog_record,
1343
220
              special_permissions,
1344
220
              error );
1345
1346
220
    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
220
  }
1358
233
  return( result );
1359
233
}
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.82k
{
1369
2.82k
  static char *function = "libfshfs_directory_entry_get_link_reference";
1370
2.82k
  int result            = 0;
1371
1372
2.82k
  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.82k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1384
2.15k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1385
603
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1386
568
   && ( 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.82k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1398
1.26k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
1399
2.12k
  {
1400
2.12k
    result = libfshfs_file_record_get_link_reference(
1401
2.12k
              (libfshfs_file_record_t *) directory_entry->catalog_record,
1402
2.12k
              link_reference,
1403
2.12k
              error );
1404
1405
2.12k
    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
2.12k
  }
1417
2.82k
  return( result );
1418
2.82k
}
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.44k
{
1429
1.44k
  static char *function = "libfshfs_directory_entry_get_utf8_name_size";
1430
1431
1.44k
  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.44k
  if( libfshfs_name_get_utf8_string_size(
1443
1.44k
       directory_entry->name,
1444
1.44k
       (size_t) directory_entry->name_size,
1445
1.44k
       directory_entry->codepage,
1446
1.44k
       utf8_string_size,
1447
1.44k
       error ) != 1 )
1448
655
  {
1449
655
    libcerror_error_set(
1450
655
     error,
1451
655
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1452
655
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1453
655
     "%s: unable to retrieve UTF-8 string size.",
1454
655
     function );
1455
1456
655
    return( -1 );
1457
655
  }
1458
793
  return( 1 );
1459
1.44k
}
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.44k
{
1471
1.44k
  static char *function = "libfshfs_directory_entry_get_utf8_name";
1472
1473
1.44k
  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.44k
  if( libfshfs_name_get_utf8_string(
1485
1.44k
       directory_entry->name,
1486
1.44k
       (size_t) directory_entry->name_size,
1487
1.44k
       directory_entry->codepage,
1488
1.44k
       utf8_string,
1489
1.44k
       utf8_string_size,
1490
1.44k
       error ) != 1 )
1491
1.05k
  {
1492
1.05k
    libcerror_error_set(
1493
1.05k
     error,
1494
1.05k
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1495
1.05k
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1496
1.05k
     "%s: unable to retrieve UTF-8 string.",
1497
1.05k
     function );
1498
1499
1.05k
    return( -1 );
1500
1.05k
  }
1501
396
  return( 1 );
1502
1.44k
}
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
2.54k
{
1596
2.54k
  static char *function = "libfshfs_directory_entry_get_data_fork_descriptor";
1597
2.54k
  int result            = 0;
1598
1599
2.54k
  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
2.54k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1611
2.50k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1612
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1613
993
   && ( 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
2.54k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1625
1.05k
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
1626
2.48k
  {
1627
2.48k
    result = libfshfs_file_record_get_data_fork_descriptor(
1628
2.48k
              (libfshfs_file_record_t *) directory_entry->catalog_record,
1629
2.48k
              fork_descriptor,
1630
2.48k
              error );
1631
1632
2.48k
    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
2.48k
  }
1644
2.54k
  return( result );
1645
2.54k
}
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
1.03k
{
1655
1.03k
  static char *function = "libfshfs_directory_entry_get_resource_fork_descriptor";
1656
1.03k
  int result            = 0;
1657
1658
1.03k
  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
1.03k
  if( ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_DIRECTORY_RECORD )
1670
1.01k
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1671
350
   && ( directory_entry->record_type != LIBFSHFS_RECORD_TYPE_HFS_DIRECTORY_RECORD )
1672
342
   && ( 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
1.03k
  if( ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFSPLUS_FILE_RECORD )
1684
369
   || ( directory_entry->record_type == LIBFSHFS_RECORD_TYPE_HFS_FILE_RECORD ) )
1685
1.01k
  {
1686
1.01k
    result = libfshfs_file_record_get_resource_fork_descriptor(
1687
1.01k
              (libfshfs_file_record_t *) directory_entry->catalog_record,
1688
1.01k
              fork_descriptor,
1689
1.01k
              error );
1690
1691
1.01k
    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
1.01k
  }
1703
1.03k
  return( result );
1704
1.03k
}
1705