/* Converts the GUID into a string * Returns 1 if successful or -1 on error */ int guid_to_string( uint8_t *guid, size_t guid_size, int byte_order, libcstring_system_character_t *string, size_t string_size, liberror_error_t **error ) { static char *function = "guid_to_string"; int print_count = 0; if( guid == NULL ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_ARGUMENTS, LIBERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid guid.", function ); return( -1 ); } if( guid_size < GUID_SIZE ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_ARGUMENTS, LIBERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, "%s: GUID too small.", function ); return( -1 ); } if( guid_size > (size_t) SSIZE_MAX ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_ARGUMENTS, LIBERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid GUID size value exceeds maximum.", function ); return( -1 ); } if( ( byte_order != _BYTE_STREAM_ENDIAN_BIG ) && ( byte_order != _BYTE_STREAM_ENDIAN_LITTLE ) ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_ARGUMENTS, LIBERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, "%s: unsupported byte order.", function ); return( -1 ); } if( string == NULL ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_ARGUMENTS, LIBERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid string.", function ); return( -1 ); } if( string_size < GUID_STRING_SIZE ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_ARGUMENTS, LIBERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, "%s: string too small.", function ); return( -1 ); } if( string_size > (size_t) SSIZE_MAX ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_ARGUMENTS, LIBERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid string size value exceeds maximum.", function ); return( -1 ); } /* Create the GUID string * It is stored as uint32 - uint16 - uint16 - 8 byte array */ if( byte_order == _BYTE_STREAM_ENDIAN_BIG ) { print_count = libcstring_system_string_sprintf( string, string_size, _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ), guid[ 0 ], guid[ 1 ], guid[ 2 ], guid[ 3 ], guid[ 4 ], guid[ 5 ], guid[ 6 ], guid[ 7 ], guid[ 8 ], guid[ 9 ], guid[ 10 ], guid[ 11 ], guid[ 12 ], guid[ 13 ], guid[ 14 ], guid[ 15 ] ); } else if( byte_order == _BYTE_STREAM_ENDIAN_LITTLE ) { print_count = libcstring_system_string_sprintf( string, string_size, _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "-%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ) _LIBCSTRING_SYSTEM_STRING( "%.2" ) _LIBCSTRING_SYSTEM_STRING( PRIx8 ), guid[ 3 ], guid[ 2 ], guid[ 1 ], guid[ 0 ], guid[ 5 ], guid[ 4 ], guid[ 7 ], guid[ 6 ], guid[ 8 ], guid[ 9 ], guid[ 10 ], guid[ 11 ], guid[ 12 ], guid[ 13 ], guid[ 14 ], guid[ 15 ] ); } if( ( print_count < 0 ) || ( (size_t) print_count > string_size ) ) { liberror_error_set( error, LIBERROR_ERROR_DOMAIN_RUNTIME, LIBERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to set string.", function ); return( -1 ); } return( 1 ); }
/* Creates a human readable byte size string * Returns 1 if successful or -1 on error */ int byte_size_string_create( libcstring_system_character_t *byte_size_string, size_t byte_size_string_length, uint64_t size, int units, libcerror_error_t **error ) { const libcstring_system_character_t *factor_string = NULL; const libcstring_system_character_t *units_string = NULL; static char *function = "byte_size_string_create"; ssize_t print_count = 0; uint64_t factored_size = 0; uint64_t last_factored_size = 0; int8_t factor = 0; int8_t remainder = -1; int decimal_point = 0; if( byte_size_string == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid byte size string.", function ); return( -1 ); } /* Minimum of 4 digits and separator, space, 3 letter unit, end of string */ if( byte_size_string_length < 9 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, "%s: byte size string too small.", function ); return( -1 ); } if( ( size < 1024 ) || ( units == BYTE_SIZE_STRING_UNIT_MEGABYTE ) ) { units_string = _LIBCSTRING_SYSTEM_STRING( "B" ); } else if( units == BYTE_SIZE_STRING_UNIT_MEBIBYTE ) { units_string = _LIBCSTRING_SYSTEM_STRING( "iB" ); } factored_size = size; if( factored_size >= (uint64_t) units ) { while( factored_size >= (uint64_t) units ) { last_factored_size = factored_size; factored_size /= units; factor++; } if( factored_size < 10 ) { last_factored_size %= units; remainder = (int8_t) ( last_factored_size / 100 ); } } if( factor > 8 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, "%s: factor size greater than 8 unsupported.", function ); return( -1 ); } switch( factor ) { case 0: factor_string = _LIBCSTRING_SYSTEM_STRING( "" ); break; case 1: factor_string = _LIBCSTRING_SYSTEM_STRING( "K" ); break; case 2: factor_string = _LIBCSTRING_SYSTEM_STRING( "M" ); break; case 3: factor_string = _LIBCSTRING_SYSTEM_STRING( "G" ); break; case 4: factor_string = _LIBCSTRING_SYSTEM_STRING( "T" ); break; case 5: factor_string = _LIBCSTRING_SYSTEM_STRING( "P" ); break; case 6: factor_string = _LIBCSTRING_SYSTEM_STRING( "E" ); break; case 7: factor_string = _LIBCSTRING_SYSTEM_STRING( "Z" ); break; case 8: factor_string = _LIBCSTRING_SYSTEM_STRING( "Y" ); break; } if( remainder > 9 ) { remainder = 9; } if( remainder >= 0 ) { if( libclocale_locale_get_decimal_point( &decimal_point, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve locale decimal point.", function ); return( -1 ); } print_count = libcstring_system_string_sprintf( byte_size_string, byte_size_string_length, _LIBCSTRING_SYSTEM_STRING( "%" ) _LIBCSTRING_SYSTEM_STRING( PRIu64 ) _LIBCSTRING_SYSTEM_STRING( "%" ) _LIBCSTRING_SYSTEM_STRING( PRIc_LIBCSTRING_SYSTEM ) _LIBCSTRING_SYSTEM_STRING( "%" ) _LIBCSTRING_SYSTEM_STRING( PRIu8 ) _LIBCSTRING_SYSTEM_STRING( " %" ) _LIBCSTRING_SYSTEM_STRING( PRIs_LIBCSTRING_SYSTEM ) _LIBCSTRING_SYSTEM_STRING( "%" ) _LIBCSTRING_SYSTEM_STRING( PRIs_LIBCSTRING_SYSTEM ), factored_size, (libcstring_system_character_t) decimal_point, remainder, factor_string, units_string ); } else { print_count = libcstring_system_string_sprintf( byte_size_string, byte_size_string_length, _LIBCSTRING_SYSTEM_STRING( "%" ) _LIBCSTRING_SYSTEM_STRING( PRIu64 ) _LIBCSTRING_SYSTEM_STRING( " %" ) _LIBCSTRING_SYSTEM_STRING( PRIs_LIBCSTRING_SYSTEM ) _LIBCSTRING_SYSTEM_STRING( "%" ) _LIBCSTRING_SYSTEM_STRING( PRIs_LIBCSTRING_SYSTEM ), factored_size, factor_string, units_string ); } if( ( print_count < 0 ) || ( (size_t) print_count > byte_size_string_length ) ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to set byte size string.", function ); return( -1 ); } return( 1 ); }
/* Exports the item * Returns 1 if successful or -1 on error */ int export_handle_export_item( export_handle_t *export_handle, libolecf_item_t *item, int item_index, int number_of_items, const libcstring_system_character_t *export_path, size_t export_path_length, log_handle_t *log_handle, libcerror_error_t **error ) { libcfile_file_t *stream_data_file = NULL; libcstring_system_character_t *item_name = NULL; libcstring_system_character_t *item_path = NULL; libcstring_system_character_t *target_path = NULL; uint8_t *buffer = NULL; static char *function = "export_handle_export_item"; size_t buffer_size = EXPORT_HANDLE_BUFFER_SIZE; size_t item_name_size = 0; size_t item_path_size = 0; size_t minimum_item_name_size = 0; size_t read_size = 0; size_t target_path_size = 0; ssize_t read_count = 0; ssize_t write_count = 0; uint32_t stream_data_size = 0; int print_count = 0; int result = 0; if( export_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid export handle.", function ); return( -1 ); } if( item == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid item.", function ); return( -1 ); } if( export_path == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid export path.", function ); return( -1 ); } log_handle_printf( log_handle, "Processing item: %05d in path: %" PRIs_LIBCSTRING_SYSTEM "%c\n", item_index, export_path, LIBCPATH_SEPARATOR ); /* Create the storage or stream directory */ #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libolecf_item_get_utf16_name_size( item, &item_name_size, error ); #else result = libolecf_item_get_utf8_name_size( item, &item_name_size, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve item name size.", function ); goto on_error; } minimum_item_name_size = item_name_size; if( minimum_item_name_size < 10 ) { minimum_item_name_size = 10; } item_name = libcstring_system_string_allocate( minimum_item_name_size ); if( item_name == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_MEMORY, LIBCERROR_MEMORY_ERROR_INSUFFICIENT, "%s: unable to create the item name.", function ); goto on_error; } #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libolecf_item_get_utf16_name( item, (uint16_t *) item_name, item_name_size, error ); #else result = libolecf_item_get_utf8_name( item, (uint8_t *) item_name, item_name_size, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve item name.", function ); goto on_error; } #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcpath_path_sanitize_filename_wide( item_name, &item_name_size, error ); #else result = libcpath_path_sanitize_filename( item_name, &item_name_size, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to sanitize item name.", function ); goto on_error; } #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcpath_path_join_wide( &item_path, &item_path_size, export_path, export_path_length, item_name, item_name_size - 1, error ); #else result = libcpath_path_join( &item_path, &item_path_size, export_path, export_path_length, item_name, item_name_size - 1, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create item path.", function ); goto on_error; } if( item_path == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid item path.", function ); goto on_error; } #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcfile_file_exists_wide( item_path, error ); #else result = libcfile_file_exists( item_path, error ); #endif if( result == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_GENERIC, "%s: unable to determine if %" PRIs_LIBCSTRING_SYSTEM " exists.", function, item_path ); goto on_error; } else if( result == 1 ) { memory_free( item_path ); item_path = NULL; print_count = libcstring_system_string_sprintf( item_name, 10, _LIBCSTRING_SYSTEM_STRING( "Item%05d" ), item_index + 1 ); if( ( print_count < 0 ) || ( print_count > 12 ) ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to set item name.", function ); goto on_error; } item_name[ 9 ] = 0; item_name_size = 10; log_handle_printf( log_handle, "Item already exists defaulting to: %" PRIs_LIBCSTRING_SYSTEM "\n", item_name ); #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcpath_path_join_wide( &item_path, &item_path_size, export_path, export_path_length, item_name, item_name_size - 1, error ); #else result = libcpath_path_join( &item_path, &item_path_size, export_path, export_path_length, item_name, item_name_size - 1, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create item path.", function ); goto on_error; } if( item_path == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid item path.", function ); goto on_error; } } memory_free( item_name ); item_name = NULL; #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcpath_path_make_directory_wide( item_path, error ); #else result = libcpath_path_make_directory( item_path, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_WRITE_FAILED, "%s: unable to make directory: %" PRIs_LIBCSTRING_SYSTEM ".", function, item_path ); goto on_error; } log_handle_printf( log_handle, "Created directory: %" PRIs_LIBCSTRING_SYSTEM ".\n", item_path ); /* Create the item file */ #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcpath_path_join_wide( &target_path, &target_path_size, item_path, item_path_size - 1, L"StreamData.bin", 14, error ); #else result = libcpath_path_join( &target_path, &target_path_size, item_path, item_path_size - 1, "StreamData.bin", 14, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create target path.", function ); goto on_error; } if( target_path == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid target path.", function ); goto on_error; } #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcfile_file_exists_wide( target_path, error ); #else result = libcfile_file_exists( target_path, error ); #endif if( result == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_GENERIC, "%s: unable to determine if %" PRIs_LIBCSTRING_SYSTEM " exists.", function, target_path ); goto on_error; } else if( result != 0 ) { log_handle_printf( log_handle, "Skipping item: %" PRIs_LIBCSTRING_SYSTEM " it already exists.\n", target_path ); memory_free( target_path ); memory_free( item_path ); return( 1 ); } if( libolecf_item_get_size( item, &stream_data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve item stream data size.", function ); goto on_error; } if( libcfile_file_initialize( &stream_data_file, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create stream data file.", function ); goto on_error; } #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libcfile_file_open_wide( stream_data_file, target_path, LIBCFILE_OPEN_WRITE, error ); #else result = libcfile_file_open( stream_data_file, target_path, LIBCFILE_OPEN_WRITE, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_OPEN_FAILED, "%s: unable to open: %" PRIs_LIBCSTRING_SYSTEM ".", function, target_path ); goto on_error; } memory_free( target_path ); target_path = NULL; if( stream_data_size > 0 ) { buffer = (uint8_t *) memory_allocate( sizeof( uint8_t ) * buffer_size ); if( buffer == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_MEMORY, LIBCERROR_MEMORY_ERROR_INSUFFICIENT, "%s: unable to create the buffer.", function ); goto on_error; } while( stream_data_size > 0 ) { read_size = buffer_size; if( read_size > stream_data_size ) { read_size = stream_data_size; } read_count = libolecf_stream_read_buffer( item, buffer, read_size, error ); if( read_count != (ssize_t) read_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read stream data from item.", function ); goto on_error; } stream_data_size -= read_size; write_count = libcfile_file_write_buffer( stream_data_file, buffer, read_size, error ); if( write_count != (ssize_t) read_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_WRITE_FAILED, "%s: unable to write stream data to file.", function ); goto on_error; } } memory_free( buffer ); buffer = NULL; } if( libcfile_file_close( stream_data_file, error ) != 0 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_CLOSE_FAILED, "%s: unable to stream data file.", function ); goto on_error; } if( libcfile_file_free( &stream_data_file, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, "%s: unable to free stream data file.", function ); goto on_error; } /* Export the sub items */ if( export_handle_export_sub_items( export_handle, item, item_path, item_path_size - 1, log_handle, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_OUTPUT, LIBCERROR_OUTPUT_ERROR_GENERIC, "%s: unable to export sub items.", function ); goto on_error; } memory_free( item_path ); item_path = NULL; return( 1 ); on_error: if( buffer != NULL ) { memory_free( buffer ); } if( stream_data_file != NULL ) { libcfile_file_free( &stream_data_file, NULL ); } if( target_path != NULL ) { memory_free( target_path ); } if( item_path != NULL ) { memory_free( item_path ); } if( item_name != NULL ) { memory_free( item_name ); } return( -1 ); }