libewf_file_entry.c 86 KB
Newer Older
1 2 3
/*
 * File entry functions
 *
4
 * Copyright (C) 2006-2017, Joachim Metz <joachim.metz@gmail.com>
5 6 7 8 9 10 11
 *
 * Refer to AUTHORS for acknowledgements.
 *
 * This software is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
12
 *
13 14 15 16
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
17
 *
18 19 20 21 22 23 24 25
 * You should have received a copy of the GNU Lesser General Public License
 * along with this software.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <common.h>
#include <memory.h>
#include <types.h>

26
#include "libewf_definitions.h"
27 28
#include "libewf_file_entry.h"
#include "libewf_handle.h"
29 30 31
#include "libewf_libcdata.h"
#include "libewf_libcerror.h"
#include "libewf_libcnotify.h"
32
#include "libewf_libcthreads.h"
33
#include "libewf_single_file_entry.h"
34
#include "libewf_single_file_tree.h"
35 36
#include "libewf_types.h"

37 38
/* Creates a file entry
 * Make sure the value file_entry is referencing, is set to NULL
39 40 41 42 43
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_initialize(
     libewf_file_entry_t **file_entry,
     libewf_internal_handle_t *internal_handle,
44 45
     libcdata_tree_node_t *file_entry_tree_node,
     libcerror_error_t **error )
46 47 48 49 50 51
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
	static char *function                             = "libewf_file_entry_initialize";

	if( file_entry == NULL )
	{
52
		libcerror_error_set(
53
		 error,
54 55
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
56 57 58 59 60
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
61 62
	if( *file_entry != NULL )
	{
63
		libcerror_error_set(
64
		 error,
65 66
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
67 68 69 70 71 72 73 74 75 76
		 "%s: invalid file entry value already set.",
		 function );

		return( -1 );
	}
	internal_file_entry = memory_allocate_structure(
	                       libewf_internal_file_entry_t );

	if( internal_file_entry == NULL )
	{
77
		libcerror_error_set(
78
		 error,
79 80
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
81 82 83 84 85 86 87 88 89
		 "%s: unable to create file entry.",
		 function );

		goto on_error;
	}
	if( memory_set(
	     internal_file_entry,
	     0,
	     sizeof( libewf_internal_file_entry_t ) ) == NULL )
90
	{
91
		libcerror_error_set(
92
		 error,
93 94
		 LIBCERROR_ERROR_DOMAIN_MEMORY,
		 LIBCERROR_MEMORY_ERROR_SET_FAILED,
95 96
		 "%s: unable to clear file entry.",
		 function );
97

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
		memory_free(
		 internal_file_entry );

		return( -1 );
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_initialize(
	     &( internal_file_entry->read_write_lock ),
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
		 "%s: unable to intialize read/write lock.",
		 function );

115 116
		goto on_error;
	}
117
#endif
118 119
	internal_file_entry->internal_handle      = internal_handle;
	internal_file_entry->file_entry_tree_node = file_entry_tree_node;
120

121 122
	*file_entry = (libewf_file_entry_t *) internal_file_entry;

123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
	return( 1 );

on_error:
	if( internal_file_entry != NULL )
	{
		memory_free(
		 internal_file_entry );
	}
	return( -1 );
}

/* Frees a file entry
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_free(
     libewf_file_entry_t **file_entry,
139
     libcerror_error_t **error )
140 141 142
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
	static char *function                             = "libewf_file_entry_free";
143
	int result                                        = 1;
144 145 146

	if( file_entry == NULL )
	{
147
		libcerror_error_set(
148
		 error,
149 150
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
151 152 153 154 155 156 157 158 159 160
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	if( *file_entry != NULL )
	{
		internal_file_entry = (libewf_internal_file_entry_t *) *file_entry;
		*file_entry         = NULL;

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
		if( libcthreads_read_write_lock_free(
		     &( internal_file_entry->read_write_lock ),
		     error ) != 1 )
		{
			libcerror_error_set(
			 error,
			 LIBCERROR_ERROR_DOMAIN_RUNTIME,
			 LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
			 "%s: unable to free read/write lock.",
			 function );

			result = -1;
		}
#endif
176
		/* The internal_handle and file_entry_tree_node references are freed elsewhere
177 178 179 180
		 */
		memory_free(
		 internal_file_entry );
	}
181
	return( result );
182 183
}

184 185 186 187 188 189
/* Retrieves the type
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_type(
     libewf_file_entry_t *file_entry,
     uint8_t *type,
190
     libcerror_error_t **error )
191 192
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
193
	libewf_single_file_entry_t *single_file_entry     = NULL;
194 195 196 197
	static char *function                             = "libewf_file_entry_get_type";

	if( file_entry == NULL )
	{
198
		libcerror_error_set(
199
		 error,
200 201
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
202 203 204 205 206 207 208
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
224 225 226 227
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
228
	{
229
		libcerror_error_set(
230
		 error,
231 232 233
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
234 235
		 function );

236
		goto on_error;
237 238
	}
	if( libewf_single_file_entry_get_type(
239
	     single_file_entry,
240 241 242
	     type,
	     error ) != 1 )
	{
243
		libcerror_error_set(
244
		 error,
245 246
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
247 248 249
		 "%s: unable to retrieve type.",
		 function );

250 251 252 253 254 255 256 257 258 259 260 261 262 263
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

264 265
		return( -1 );
	}
266
#endif
267
	return( 1 );
268 269 270 271 272 273 274 275

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
276 277
}

278 279 280 281 282 283
/* Retrieves the flags
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_flags(
     libewf_file_entry_t *file_entry,
     uint32_t *flags,
284
     libcerror_error_t **error )
285 286
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
287
	libewf_single_file_entry_t *single_file_entry     = NULL;
288 289 290 291
	static char *function                             = "libewf_file_entry_get_flags";

	if( file_entry == NULL )
	{
292
		libcerror_error_set(
293
		 error,
294 295
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
296 297 298 299 300 301 302
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
318 319 320 321
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
322
	{
323
		libcerror_error_set(
324
		 error,
325 326 327
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
328 329
		 function );

330
		goto on_error;
331 332
	}
	if( libewf_single_file_entry_get_flags(
333
	     single_file_entry,
334 335 336
	     flags,
	     error ) != 1 )
	{
337
		libcerror_error_set(
338
		 error,
339 340
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
341
		 "%s: unable to retrieve flags.",
342 343
		 function );

344 345 346 347 348 349 350 351 352 353 354 355 356 357
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

358 359
		return( -1 );
	}
360
#endif
361
	return( 1 );
362 363 364 365 366 367 368 369

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
370 371
}

372 373 374 375 376 377
/* Retrieves the media data offset
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_media_data_offset(
     libewf_file_entry_t *file_entry,
     off64_t *media_data_offset,
378
     libcerror_error_t **error )
379 380
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
381
	libewf_single_file_entry_t *single_file_entry     = NULL;
382 383 384 385
	static char *function                             = "libewf_file_entry_get_media_data_offset";

	if( file_entry == NULL )
	{
386
		libcerror_error_set(
387
		 error,
388 389
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
390 391 392 393 394 395 396
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
412 413 414 415
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
416
	{
417
		libcerror_error_set(
418
		 error,
419 420 421
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
422 423
		 function );

424
		goto on_error;
425 426
	}
	if( libewf_single_file_entry_get_data_offset(
427
	     single_file_entry,
428 429 430
	     media_data_offset,
	     error ) != 1 )
	{
431
		libcerror_error_set(
432
		 error,
433 434
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
435 436 437
		 "%s: unable to retrieve data offset.",
		 function );

438 439 440 441 442 443 444 445 446 447 448 449 450 451
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

452 453
		return( -1 );
	}
454
#endif
455
	return( 1 );
456 457 458 459 460 461 462 463

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
464 465 466 467 468 469 470 471
}

/* Retrieves the media data size
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_media_data_size(
     libewf_file_entry_t *file_entry,
     size64_t *media_data_size,
472
     libcerror_error_t **error )
473 474
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
475
	libewf_single_file_entry_t *single_file_entry     = NULL;
476 477 478 479
	static char *function                             = "libewf_file_entry_get_media_data_size";

	if( file_entry == NULL )
	{
480
		libcerror_error_set(
481
		 error,
482 483
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
484 485 486 487 488 489 490
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
506 507 508 509
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
510
	{
511
		libcerror_error_set(
512
		 error,
513 514 515
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
516 517
		 function );

518
		goto on_error;
519 520
	}
	if( libewf_single_file_entry_get_data_size(
521
	     single_file_entry,
522 523 524
	     media_data_size,
	     error ) != 1 )
	{
525
		libcerror_error_set(
526
		 error,
527 528
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
529 530 531
		 "%s: unable to retrieve data size.",
		 function );

532 533 534 535 536 537 538 539 540 541 542 543 544 545
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

546 547
		return( -1 );
	}
548
#endif
549
	return( 1 );
550 551 552 553 554 555 556 557

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
558 559 560 561 562 563 564 565
}

/* Retrieves the duplicate media data offset
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_duplicate_media_data_offset(
     libewf_file_entry_t *file_entry,
     off64_t *duplicate_media_data_offset,
566
     libcerror_error_t **error )
567 568
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
569
	libewf_single_file_entry_t *single_file_entry     = NULL;
570 571 572 573
	static char *function                             = "libewf_file_entry_get_media_data_offset";

	if( file_entry == NULL )
	{
574
		libcerror_error_set(
575
		 error,
576 577
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
578 579 580 581 582 583 584
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
600 601 602 603
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
604
	{
605
		libcerror_error_set(
606
		 error,
607 608 609
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
610 611
		 function );

612
		goto on_error;
613 614
	}
	if( libewf_single_file_entry_get_duplicate_data_offset(
615
	     single_file_entry,
616 617 618
	     duplicate_media_data_offset,
	     error ) != 1 )
	{
619
		libcerror_error_set(
620
		 error,
621 622
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
623 624 625
		 "%s: unable to retrieve duplicate data offset.",
		 function );

626 627 628 629 630 631 632 633 634 635 636 637 638 639
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

640 641
		return( -1 );
	}
642
#endif
643
	return( 1 );
644 645 646 647 648 649 650 651

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
652 653
}

654 655 656 657 658 659 660
/* Retrieves the size of the UTF-8 encoded name
 * The returned size includes the end of string character
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_utf8_name_size(
     libewf_file_entry_t *file_entry,
     size_t *utf8_name_size,
661
     libcerror_error_t **error )
662 663
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
664
	libewf_single_file_entry_t *single_file_entry     = NULL;
665 666 667 668
	static char *function                             = "libewf_file_entry_get_utf8_name_size";

	if( file_entry == NULL )
	{
669
		libcerror_error_set(
670
		 error,
671 672
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
673 674 675 676 677 678 679
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
695 696 697 698
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
699
	{
700
		libcerror_error_set(
701
		 error,
702 703 704
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
705 706
		 function );

707
		goto on_error;
708 709
	}
	if( libewf_single_file_entry_get_utf8_name_size(
710
	     single_file_entry,
711 712 713
	     utf8_name_size,
	     error ) != 1 )
	{
714
		libcerror_error_set(
715
		 error,
716 717
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
718 719 720
		 "%s: unable to retrieve UTF-8 name size.",
		 function );

721 722 723 724 725 726 727 728 729 730 731 732 733 734
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

735 736
		return( -1 );
	}
737
#endif
738
	return( 1 );
739 740 741 742 743 744 745 746

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
747 748 749 750 751 752 753 754 755 756
}

/* Retrieves the UTF-8 encoded name value
 * The size should include the end of string character
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_utf8_name(
     libewf_file_entry_t *file_entry,
     uint8_t *utf8_name,
     size_t utf8_name_size,
757
     libcerror_error_t **error )
758 759
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
760
	libewf_single_file_entry_t *single_file_entry     = NULL;
761
	static char *function                             = "libewf_file_entry_get_utf8_name";
762 763 764

	if( file_entry == NULL )
	{
765
		libcerror_error_set(
766
		 error,
767 768
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
769 770 771 772 773 774 775
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

776 777 778 779 780 781 782 783 784 785 786 787 788 789 790
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
791 792 793 794
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
795
	{
796
		libcerror_error_set(
797
		 error,
798 799 800
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
801 802
		 function );

803
		goto on_error;
804 805
	}
	if( libewf_single_file_entry_get_utf8_name(
806
	     single_file_entry,
807 808 809 810
	     utf8_name,
	     utf8_name_size,
	     error ) != 1 )
	{
811
		libcerror_error_set(
812
		 error,
813 814
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
815 816 817
		 "%s: unable to retrieve UTF-8 name.",
		 function );

818 819 820 821 822 823 824 825 826 827 828 829 830 831
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

832 833
		return( -1 );
	}
834
#endif
835
	return( 1 );
836 837 838 839 840 841 842 843

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
844 845 846 847 848 849 850 851 852
}

/* Retrieves the size of the UTF-16 encoded name
 * The returned size includes the end of string character
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_utf16_name_size(
     libewf_file_entry_t *file_entry,
     size_t *utf16_name_size,
853
     libcerror_error_t **error )
854 855
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
856
	libewf_single_file_entry_t *single_file_entry     = NULL;
857 858 859 860
	static char *function                             = "libewf_file_entry_get_utf16_name_size";

	if( file_entry == NULL )
	{
861
		libcerror_error_set(
862
		 error,
863 864
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
865 866 867 868 869 870 871
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

872 873 874 875 876 877 878 879 880 881 882 883 884 885 886
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
887 888 889 890
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
891
	{
892
		libcerror_error_set(
893
		 error,
894 895 896
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
897 898
		 function );

899
		goto on_error;
900 901
	}
	if( libewf_single_file_entry_get_utf16_name_size(
902
	     single_file_entry,
903 904 905
	     utf16_name_size,
	     error ) != 1 )
	{
906
		libcerror_error_set(
907
		 error,
908 909
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
910 911 912
		 "%s: unable to retrieve UTF-16 name size.",
		 function );

913 914 915 916 917 918 919 920 921 922 923 924 925 926
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

927 928
		return( -1 );
	}
929
#endif
930
	return( 1 );
931 932 933 934 935 936 937 938

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
939 940 941 942 943 944 945 946 947 948
}

/* Retrieves the UTF-16 encoded name value
 * The size should include the end of string character
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_utf16_name(
     libewf_file_entry_t *file_entry,
     uint16_t *utf16_name,
     size_t utf16_name_size,
949
     libcerror_error_t **error )
950 951
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
952
	libewf_single_file_entry_t *single_file_entry     = NULL;
953
	static char *function                             = "libewf_file_entry_get_utf16_name";
954 955 956

	if( file_entry == NULL )
	{
957
		libcerror_error_set(
958
		 error,
959 960
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
961 962 963 964 965 966 967
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
983 984 985 986
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
987
	{
988
		libcerror_error_set(
989
		 error,
990 991 992
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
993 994
		 function );

995
		goto on_error;
996 997
	}
	if( libewf_single_file_entry_get_utf16_name(
998
	     single_file_entry,
999 1000 1001 1002
	     utf16_name,
	     utf16_name_size,
	     error ) != 1 )
	{
1003
		libcerror_error_set(
1004
		 error,
1005 1006
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1007 1008 1009
		 "%s: unable to retrieve UTF-8 name.",
		 function );

1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

1024 1025
		return( -1 );
	}
1026
#endif
1027
	return( 1 );
1028 1029 1030 1031 1032 1033 1034 1035

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
1036 1037 1038 1039 1040 1041 1042 1043
}

/* Retrieves the size
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_size(
     libewf_file_entry_t *file_entry,
     size64_t *size,
1044
     libcerror_error_t **error )
1045 1046
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
1047
	libewf_single_file_entry_t *single_file_entry     = NULL;
1048 1049 1050 1051
	static char *function                             = "libewf_file_entry_get_size";

	if( file_entry == NULL )
	{
1052
		libcerror_error_set(
1053
		 error,
1054 1055
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1056 1057 1058 1059 1060 1061 1062
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
1078 1079 1080 1081
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
1082
	{
1083
		libcerror_error_set(
1084
		 error,
1085 1086 1087
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
1088 1089
		 function );

1090
		goto on_error;
1091 1092
	}
	if( libewf_single_file_entry_get_size(
1093
	     single_file_entry,
1094 1095 1096
	     size,
	     error ) != 1 )
	{
1097
		libcerror_error_set(
1098
		 error,
1099 1100
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1101 1102 1103
		 "%s: unable to retrieve size.",
		 function );

1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

1118 1119
		return( -1 );
	}
1120
#endif
1121
	return( 1 );
1122 1123 1124 1125 1126 1127 1128 1129

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
1130 1131 1132 1133 1134 1135 1136
}

/* Retrieves the creation date and time
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_creation_time(
     libewf_file_entry_t *file_entry,
1137
     uint32_t *creation_time,
1138
     libcerror_error_t **error )
1139 1140
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
1141
	libewf_single_file_entry_t *single_file_entry     = NULL;
1142 1143 1144 1145
	static char *function                             = "libewf_file_entry_get_creation_time";

	if( file_entry == NULL )
	{
1146
		libcerror_error_set(
1147
		 error,
1148 1149
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1150 1151 1152 1153 1154 1155 1156
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
1172 1173 1174 1175
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
1176
	{
1177
		libcerror_error_set(
1178
		 error,
1179 1180 1181
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
1182 1183
		 function );

1184
		goto on_error;
1185 1186
	}
	if( libewf_single_file_entry_get_creation_time(
1187
	     single_file_entry,
1188 1189 1190
	     creation_time,
	     error ) != 1 )
	{
1191
		libcerror_error_set(
1192
		 error,
1193 1194
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1195 1196 1197
		 "%s: unable to retrieve creation time.",
		 function );

1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

1212 1213
		return( -1 );
	}
1214
#endif
1215
	return( 1 );
1216 1217 1218 1219 1220 1221 1222 1223

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
1224 1225 1226 1227 1228 1229 1230
}

/* Retrieves the (file) modification (last written) date and time
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_modification_time(
     libewf_file_entry_t *file_entry,
1231
     uint32_t *modification_time,
1232
     libcerror_error_t **error )
1233 1234
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
1235
	libewf_single_file_entry_t *single_file_entry     = NULL;
1236 1237 1238 1239
	static char *function                             = "libewf_file_entry_get_modification_time";

	if( file_entry == NULL )
	{
1240
		libcerror_error_set(
1241
		 error,
1242 1243
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1244 1245 1246 1247 1248 1249 1250
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
1266 1267 1268 1269
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
1270
	{
1271
		libcerror_error_set(
1272
		 error,
1273 1274 1275
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
1276 1277
		 function );

1278
		goto on_error;
1279 1280
	}
	if( libewf_single_file_entry_get_modification_time(
1281
	     single_file_entry,
1282 1283 1284
	     modification_time,
	     error ) != 1 )
	{
1285
		libcerror_error_set(
1286
		 error,
1287 1288
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1289 1290 1291
		 "%s: unable to retrieve modification time.",
		 function );

1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

1306 1307
		return( -1 );
	}
1308
#endif
1309
	return( 1 );
1310 1311 1312 1313 1314 1315 1316 1317

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
1318 1319 1320 1321 1322 1323 1324
}

/* Retrieves the access date and time
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_access_time(
     libewf_file_entry_t *file_entry,
1325
     uint32_t *access_time,
1326
     libcerror_error_t **error )
1327 1328
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
1329
	libewf_single_file_entry_t *single_file_entry     = NULL;
1330 1331 1332 1333
	static char *function                             = "libewf_file_entry_get_access_time";

	if( file_entry == NULL )
	{
1334
		libcerror_error_set(
1335
		 error,
1336 1337
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1338 1339 1340 1341 1342 1343 1344
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
1360 1361 1362 1363
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
1364
	{
1365
		libcerror_error_set(
1366
		 error,
1367 1368 1369
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
1370 1371
		 function );

1372
		goto on_error;
1373 1374
	}
	if( libewf_single_file_entry_get_access_time(
1375
	     single_file_entry,
1376 1377 1378
	     access_time,
	     error ) != 1 )
	{
1379
		libcerror_error_set(
1380
		 error,
1381 1382
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1383 1384 1385
		 "%s: unable to retrieve access time.",
		 function );

1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

1400 1401
		return( -1 );
	}
1402
#endif
1403
	return( 1 );
1404 1405 1406 1407 1408 1409 1410 1411

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
1412 1413 1414 1415 1416 1417 1418
}

/* Retrieves the (file system entry) modification date and time
 * Returns 1 if successful or -1 on error
 */
int libewf_file_entry_get_entry_modification_time(
     libewf_file_entry_t *file_entry,
1419
     uint32_t *entry_modification_time,
1420
     libcerror_error_t **error )
1421 1422
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
1423
	libewf_single_file_entry_t *single_file_entry     = NULL;
1424 1425 1426 1427
	static char *function                             = "libewf_file_entry_get_entry_modification_time";

	if( file_entry == NULL )
	{
1428
		libcerror_error_set(
1429
		 error,
1430 1431
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1432 1433 1434 1435 1436 1437 1438
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
1454 1455 1456 1457
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
1458
	{
1459
		libcerror_error_set(
1460
		 error,
1461 1462 1463
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
1464 1465
		 function );

1466
		goto on_error;
1467 1468
	}
	if( libewf_single_file_entry_get_entry_modification_time(
1469
	     single_file_entry,
1470 1471 1472
	     entry_modification_time,
	     error ) != 1 )
	{
1473
		libcerror_error_set(
1474
		 error,
1475 1476
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1477 1478 1479
		 "%s: unable to retrieve entry modification time.",
		 function );

1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

1494 1495
		return( -1 );
	}
1496
#endif
1497
	return( 1 );
1498 1499 1500 1501 1502 1503 1504 1505

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
1506 1507 1508 1509 1510 1511 1512 1513 1514
}

/* Retrieves the UTF-8 encoded MD5 hash value
 * Returns 1 if successful, 0 if value not present or -1 on error
 */
int libewf_file_entry_get_utf8_hash_value_md5(
     libewf_file_entry_t *file_entry,
     uint8_t *utf8_string,
     size_t utf8_string_size,
1515
     libcerror_error_t **error )
1516 1517
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
1518
	libewf_single_file_entry_t *single_file_entry     = NULL;
1519 1520 1521 1522 1523
	static char *function                             = "libewf_file_entry_get_utf8_hash_value_md5";
	int result                                        = 0;

	if( file_entry == NULL )
	{
1524
		libcerror_error_set(
1525
		 error,
1526 1527
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1528 1529 1530 1531 1532 1533 1534
		 "%s: invalid file entry.",
		 function );

		return( -1 );
	}
	internal_file_entry = (libewf_internal_file_entry_t *) file_entry;

1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_grab_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to grab read/write lock for reading.",
		 function );

		return( -1 );
	}
#endif
1550 1551 1552 1553
	if( libcdata_tree_node_get_value(
	     internal_file_entry->file_entry_tree_node,
	     (intptr_t **) &single_file_entry,
	     error ) != 1 )
1554
	{
1555
		libcerror_error_set(
1556
		 error,
1557 1558 1559
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve value from file entry tree node.",
1560 1561
		 function );

1562
		goto on_error;
1563 1564
	}
	result = libewf_single_file_entry_get_utf8_hash_value_md5(
1565 1566 1567 1568
		  single_file_entry,
		  utf8_string,
		  utf8_string_size,
		  error );
1569 1570 1571

	if( result == -1 )
	{
1572
		libcerror_error_set(
1573
		 error,
1574 1575
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1576 1577 1578
		 "%s: unable to retrieve hash value: MD5.",
		 function );

1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592
		goto on_error;
	}
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	if( libcthreads_read_write_lock_release_for_read(
	     internal_file_entry->read_write_lock,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to release read/write lock for reading.",
		 function );

1593 1594
		return( -1 );
	}
1595
#endif
1596
	return( result );
1597 1598 1599 1600 1601 1602 1603 1604

on_error:
#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT )
	libcthreads_read_write_lock_release_for_read(
	 internal_file_entry->read_write_lock,
	 NULL );
#endif
	return( -1 );
1605 1606 1607 1608 1609 1610 1611 1612 1613
}

/* Retrieves the UTF-16 encoded MD5 hash value
 * Returns 1 if successful, 0 if value not present or -1 on error
 */
int libewf_file_entry_get_utf16_hash_value_md5(
     libewf_file_entry_t *file_entry,
     uint16_t *utf16_string,
     size_t utf16_string_size,
1614
     libcerror_error_t **error )
1615 1616
{
	libewf_internal_file_entry_t *internal_file_entry = NULL;
1617
	libewf_single_file_entry_t *single_file_entry     = NULL;
Christophe Monniez's avatar