mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2026-04-05 21:51:03 +00:00
refactor: update file I/O to support large files with aaru_off_t type
This commit is contained in:
8
3rdparty/lzma.cmake
vendored
8
3rdparty/lzma.cmake
vendored
@@ -3,10 +3,10 @@ set("LZMA_ASM_DIRECTORY" "3rdparty/lzma-21.03beta/Asm")
|
||||
|
||||
message(STATUS "LZMA VERSION: 21.03beta")
|
||||
|
||||
target_compile_definitions(aaruformat PUBLIC _REENTRANT)
|
||||
target_compile_definitions(aaruformat PUBLIC _FILE_OFFSET_BITS)
|
||||
target_compile_definitions(aaruformat PUBLIC _LARGEFILE_SOURCE)
|
||||
target_compile_definitions(aaruformat PUBLIC _7ZIP_ST)
|
||||
target_compile_definitions(aaruformat PRIVATE _REENTRANT)
|
||||
target_compile_definitions(aaruformat PRIVATE _FILE_OFFSET_BITS=64)
|
||||
target_compile_definitions(aaruformat PRIVATE _LARGEFILE_SOURCE)
|
||||
target_compile_definitions(aaruformat PRIVATE _7ZIP_ST)
|
||||
|
||||
# All assembly for x86 and x64 disabled because it uses a custom, non GAS, non MASM, assembler
|
||||
|
||||
|
||||
@@ -83,6 +83,20 @@ if(NOT WIN32)
|
||||
add_compile_definitions(_POSIX_C_SOURCE=200809L)
|
||||
endif()
|
||||
|
||||
# Configure large-file support consistently across compilers and architectures.
|
||||
# POSIX builds use fseeko()/ftello() with 64-bit file offsets, while Windows
|
||||
# builds route stdio positioning through the native 64-bit APIs.
|
||||
function(aaru_enable_large_file_support target)
|
||||
if(WIN32)
|
||||
target_compile_definitions(${target} PRIVATE AARU_USE_WIN32_FILEIO64)
|
||||
else()
|
||||
target_compile_definitions(${target} PRIVATE
|
||||
_FILE_OFFSET_BITS=64
|
||||
_LARGEFILE_SOURCE
|
||||
AARU_USE_POSIX_FILEIO64)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# MinGW specific configuration
|
||||
if("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
|
||||
@@ -288,6 +302,8 @@ target_include_directories(aaruformat
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/uthash/src
|
||||
)
|
||||
|
||||
aaru_enable_large_file_support(aaruformat)
|
||||
|
||||
# Load third-party dependencies
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")
|
||||
|
||||
|
||||
@@ -22,6 +22,37 @@
|
||||
/** @brief Clamp num_threads to LZMA's valid range [1, 2]. */
|
||||
#define LZMA_THREADS(ctx) ((ctx)->num_threads > 1 ? 2 : 1)
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(AARU_USE_WIN32_FILEIO64)
|
||||
#define AARU_FSEEK _fseeki64
|
||||
#define AARU_FTELL _ftelli64
|
||||
#elif defined(AARU_USE_POSIX_FILEIO64)
|
||||
#define AARU_FSEEK fseeko
|
||||
#define AARU_FTELL ftello
|
||||
#else
|
||||
#define AARU_FSEEK fseek
|
||||
#define AARU_FTELL ftell
|
||||
#endif
|
||||
|
||||
typedef int64_t aaru_off_t;
|
||||
|
||||
static inline int aaruf_fseek(FILE *stream, aaru_off_t offset, int origin)
|
||||
{
|
||||
return AARU_FSEEK(stream, offset, origin);
|
||||
}
|
||||
|
||||
static inline aaru_off_t aaruf_ftell(FILE *stream)
|
||||
{
|
||||
return (aaru_off_t)AARU_FTELL(stream);
|
||||
}
|
||||
|
||||
#ifndef AARU_NO_FILEIO_REMAP
|
||||
#define fseek(stream, offset, origin) aaruf_fseek((stream), (aaru_off_t)(offset), (origin))
|
||||
#define ftell(stream) aaruf_ftell((stream))
|
||||
#endif
|
||||
|
||||
#include "utarray.h"
|
||||
|
||||
UT_array *process_index_v1(aaruformat_context *ctx);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "aaruformat/enums.h"
|
||||
#include "aaruformat/structs/checksum.h"
|
||||
#include "aaruformat/structs/index.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "aaruformat.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
#include "uthash.h"
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ void process_dumphw_block(aaruformat_context *ctx, const IndexEntry *entry)
|
||||
|
||||
free(payload);
|
||||
|
||||
if(fseek(ctx->imageStream, -(long)payload_length, SEEK_CUR) != 0)
|
||||
if(fseek(ctx->imageStream, -(aaru_off_t)payload_length, SEEK_CUR) != 0)
|
||||
{
|
||||
TRACE("Could not rewind after CRC verification");
|
||||
reset_dump_hardware_context(ctx);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "aaruformat/structs/index.h"
|
||||
#include "consts.h"
|
||||
#include "decls.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
#include "utarray.h"
|
||||
#include "uthash.h"
|
||||
@@ -857,7 +858,7 @@ static int32_t read_flux_payload_header(const aaruformat_context *ctx, uint64_t
|
||||
return AARUF_ERROR_CANNOT_READ_BLOCK;
|
||||
}
|
||||
|
||||
long file_position = ftell(ctx->imageStream);
|
||||
aaru_off_t file_position = ftell(ctx->imageStream);
|
||||
if(file_position < 0 || (uint64_t)file_position != payload_offset)
|
||||
{
|
||||
FATAL("Invalid flux payload position (expected %" PRIu64 ", got %ld)", payload_offset, file_position);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "aaruformat.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "aaruformat.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* */
|
||||
|
||||
#include "aaruformat.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,7 +78,7 @@ static int32_t write_cached_secondary_ddt(aaruformat_context *ctx)
|
||||
TRACE("Writing cached secondary DDT table to file");
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long end_of_file = ftell(ctx->imageStream);
|
||||
aaru_off_t end_of_file = ftell(ctx->imageStream);
|
||||
|
||||
// Align the position according to block alignment shift
|
||||
uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
@@ -241,7 +241,7 @@ static int32_t write_cached_secondary_ddt(aaruformat_context *ctx)
|
||||
TRACE("Added new DDT index entry at offset %" PRIu64, end_of_file);
|
||||
|
||||
// Write the updated primary table back to its original position in the file
|
||||
long saved_pos = ftell(ctx->imageStream);
|
||||
aaru_off_t saved_pos = ftell(ctx->imageStream);
|
||||
fseek(ctx->imageStream, ctx->primary_ddt_offset + sizeof(DdtHeader2), SEEK_SET);
|
||||
|
||||
size_t primary_table_size = ctx->user_data_ddt_header.entries * sizeof(uint64_t);
|
||||
@@ -486,7 +486,7 @@ static int32_t write_single_level_ddt(aaruformat_context *ctx)
|
||||
|
||||
// Write the DDT header first
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long ddt_position = ftell(ctx->imageStream);
|
||||
aaru_off_t ddt_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(ddt_position & alignment_mask)
|
||||
@@ -760,7 +760,7 @@ static void write_checksum_block(aaruformat_context *ctx)
|
||||
checksum_header.identifier = ChecksumBlock;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long checksum_position = ftell(ctx->imageStream);
|
||||
aaru_off_t checksum_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(checksum_position & alignment_mask)
|
||||
@@ -878,7 +878,7 @@ static void write_tracks_block(aaruformat_context *ctx)
|
||||
if(ctx->tracks_header.entries <= 0 || ctx->track_entries == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long tracks_position = ftell(ctx->imageStream);
|
||||
aaru_off_t tracks_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(tracks_position & alignment_mask)
|
||||
@@ -944,7 +944,7 @@ static void write_mode2_subheaders_block(aaruformat_context *ctx)
|
||||
if(ctx->mode2_subheaders == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long mode2_subheaders_position = ftell(ctx->imageStream);
|
||||
aaru_off_t mode2_subheaders_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(mode2_subheaders_position & alignment_mask)
|
||||
@@ -1090,7 +1090,7 @@ static void write_sector_prefix(aaruformat_context *ctx)
|
||||
if(ctx->sector_prefix == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long prefix_position = ftell(ctx->imageStream);
|
||||
aaru_off_t prefix_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(prefix_position & alignment_mask)
|
||||
@@ -1243,7 +1243,7 @@ static void write_sector_suffix(aaruformat_context *ctx)
|
||||
if(ctx->sector_suffix == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long suffix_position = ftell(ctx->imageStream);
|
||||
aaru_off_t suffix_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(suffix_position & alignment_mask)
|
||||
@@ -1392,7 +1392,7 @@ static void write_sector_prefix_ddt(aaruformat_context *ctx)
|
||||
if(ctx->sector_prefix_ddt2 == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long prefix_ddt_position = ftell(ctx->imageStream);
|
||||
aaru_off_t prefix_ddt_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(prefix_ddt_position & alignment_mask)
|
||||
@@ -1569,7 +1569,7 @@ static void write_sector_suffix_ddt(aaruformat_context *ctx)
|
||||
if(ctx->sector_suffix_ddt2 == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long suffix_ddt_position = ftell(ctx->imageStream);
|
||||
aaru_off_t suffix_ddt_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(suffix_ddt_position & alignment_mask)
|
||||
@@ -1760,7 +1760,7 @@ static void write_sector_subchannel(aaruformat_context *ctx)
|
||||
if(ctx->sector_subchannel == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
// Align index position to block boundary if needed
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(block_position & alignment_mask)
|
||||
@@ -2111,7 +2111,7 @@ static void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
|
||||
// Write DVD sector ID block
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long id_position = ftell(ctx->imageStream);
|
||||
aaru_off_t id_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(id_position & alignment_mask)
|
||||
{
|
||||
@@ -2227,7 +2227,7 @@ static void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
|
||||
// Write DVD sector IED block
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long ied_position = ftell(ctx->imageStream);
|
||||
aaru_off_t ied_position = ftell(ctx->imageStream);
|
||||
if(ied_position & alignment_mask)
|
||||
{
|
||||
const uint64_t aligned_position = ied_position + alignment_mask & ~alignment_mask;
|
||||
@@ -2340,7 +2340,7 @@ static void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
|
||||
// Write DVD sector CPR/MAI block
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long cpr_mai_position = ftell(ctx->imageStream);
|
||||
aaru_off_t cpr_mai_position = ftell(ctx->imageStream);
|
||||
if(cpr_mai_position & alignment_mask)
|
||||
{
|
||||
const uint64_t aligned_position = cpr_mai_position + alignment_mask & ~alignment_mask;
|
||||
@@ -2453,7 +2453,7 @@ static void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
|
||||
// Write DVD sector EDC block
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long edc_position = ftell(ctx->imageStream);
|
||||
aaru_off_t edc_position = ftell(ctx->imageStream);
|
||||
if(edc_position & alignment_mask)
|
||||
{
|
||||
const uint64_t aligned_position = edc_position + alignment_mask & ~alignment_mask;
|
||||
@@ -2667,7 +2667,7 @@ static void write_dvd_title_key_decrypted_block(aaruformat_context *ctx)
|
||||
if(ctx->sector_decrypted_title_key == NULL) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(block_position & alignment_mask)
|
||||
{
|
||||
@@ -2869,7 +2869,7 @@ static void write_media_tags(aaruformat_context *ctx)
|
||||
HASH_ITER(hh, ctx->mediaTags, media_tag, tmp_media_tag)
|
||||
{
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long tag_position = ftell(ctx->imageStream);
|
||||
aaru_off_t tag_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(tag_position & alignment_mask)
|
||||
{
|
||||
@@ -3185,7 +3185,7 @@ static void write_tape_file_block(aaruformat_context *ctx)
|
||||
|
||||
// Write tape file block to file, block aligned
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(block_position & alignment_mask)
|
||||
{
|
||||
@@ -3431,7 +3431,7 @@ static void write_tape_partition_block(aaruformat_context *ctx)
|
||||
|
||||
// Write tape partition block to partition, block aligned
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(block_position & alignment_mask)
|
||||
{
|
||||
@@ -3540,7 +3540,7 @@ static void write_geometry_block(aaruformat_context *ctx)
|
||||
if(ctx->geometry_block.identifier != GeometryBlock) return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(block_position & alignment_mask)
|
||||
{
|
||||
@@ -3794,7 +3794,7 @@ static void write_metadata_block(aaruformat_context *ctx)
|
||||
}
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(block_position & alignment_mask)
|
||||
{
|
||||
@@ -4092,7 +4092,7 @@ static void write_dumphw_block(aaruformat_context *ctx)
|
||||
memcpy(buffer, &ctx->dump_hardware_header, sizeof(DumpHardwareHeader));
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(block_position & alignment_mask)
|
||||
{
|
||||
@@ -4231,7 +4231,7 @@ static void write_cicm_block(aaruformat_context *ctx)
|
||||
return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
|
||||
if(block_position & alignment_mask)
|
||||
@@ -4382,7 +4382,7 @@ static void write_aaru_json_block(aaruformat_context *ctx)
|
||||
return;
|
||||
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long block_position = ftell(ctx->imageStream);
|
||||
aaru_off_t block_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
|
||||
if(block_position & alignment_mask)
|
||||
@@ -4730,7 +4730,7 @@ static int32_t write_flux_capture_payload(aaruformat_context *ctx, FluxCaptureRe
|
||||
|
||||
// Align stream position to block boundary
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long payload_position = ftell(ctx->imageStream);
|
||||
aaru_off_t payload_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(payload_position & alignment_mask)
|
||||
{
|
||||
@@ -5076,7 +5076,7 @@ static int32_t write_flux_blocks(aaruformat_context *ctx)
|
||||
|
||||
// Align stream position to block boundary
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long metadata_position = ftell(ctx->imageStream);
|
||||
aaru_off_t metadata_position = ftell(ctx->imageStream);
|
||||
const uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
if(metadata_position & alignment_mask)
|
||||
{
|
||||
@@ -5146,7 +5146,7 @@ static int32_t write_index_block(aaruformat_context *ctx)
|
||||
// Write the complete index at the end of the file
|
||||
TRACE("Writing index at the end of the file");
|
||||
fseek(ctx->imageStream, 0, SEEK_END);
|
||||
long index_position = ftell(ctx->imageStream);
|
||||
aaru_off_t index_position = ftell(ctx->imageStream);
|
||||
|
||||
// Align index position to block boundary if needed
|
||||
uint64_t alignment_mask = (1ULL << ctx->user_data_ddt_header.blockAlignmentShift) - 1;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include "aaruformat.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -1580,7 +1580,7 @@ bool set_ddt_multi_level_v2(aaruformat_context *ctx, uint64_t sector_address, bo
|
||||
ctx->dirty_primary_ddt = true; // Mark primary DDT as dirty
|
||||
|
||||
// Write the updated primary table back to its original position in the file
|
||||
long saved_pos = ftell(ctx->imageStream);
|
||||
aaru_off_t saved_pos = ftell(ctx->imageStream);
|
||||
fseek(ctx->imageStream, ctx->primary_ddt_offset + sizeof(DdtHeader2), SEEK_SET);
|
||||
|
||||
size_t primary_table_size = ctx->user_data_ddt_header.entries * sizeof(uint64_t);
|
||||
@@ -1802,7 +1802,7 @@ bool set_ddt_multi_level_v2(aaruformat_context *ctx, uint64_t sector_address, bo
|
||||
ctx->dirty_primary_ddt = true; // Mark primary DDT as dirty
|
||||
|
||||
// Write the updated primary table back to its original position in the file
|
||||
long saved_pos = ftell(ctx->imageStream);
|
||||
aaru_off_t saved_pos = ftell(ctx->imageStream);
|
||||
fseek(ctx->imageStream, ctx->primary_ddt_offset + sizeof(DdtHeader2), SEEK_SET);
|
||||
|
||||
size_t primary_table_size = ctx->user_data_ddt_header.entries * sizeof(uint64_t);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/**
|
||||
* @brief Identifies a file as an AaruFormat image using a file path.
|
||||
*
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "aaruformat.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
#include "utarray.h"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "aaruformat.h"
|
||||
#include "internal.h"
|
||||
#include "log.h"
|
||||
#include "utarray.h"
|
||||
|
||||
|
||||
@@ -923,7 +923,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void *context, const uint64_t se
|
||||
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
fseek(ctx->imageStream, (long)(block_offset + sizeof(BlockHeader)), SEEK_SET);
|
||||
fseek(ctx->imageStream, (aaru_off_t)(block_offset + sizeof(BlockHeader)), SEEK_SET);
|
||||
|
||||
read_bytes = fread(cmp_data, 1, block_header->cmpLength, ctx->imageStream);
|
||||
if(read_bytes != block_header->cmpLength)
|
||||
|
||||
@@ -99,6 +99,7 @@ add_executable(tests_run
|
||||
ps3_sfo.cpp
|
||||
ps3_iso9660.cpp
|
||||
ngcw.cpp
|
||||
large_file_io.cpp
|
||||
mode2_nocrc.cpp
|
||||
mode2_errored.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/aes128.c
|
||||
@@ -112,6 +113,8 @@ add_executable(tests_run
|
||||
../tool/ps3/iso9660_mini.c
|
||||
)
|
||||
|
||||
aaru_enable_large_file_support(tests_run)
|
||||
|
||||
# Set up include directories using modern target-specific approach
|
||||
target_include_directories(tests_run
|
||||
PRIVATE
|
||||
|
||||
51
tests/large_file_io.cpp
Normal file
51
tests/large_file_io.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2026 Natalia Portillo.
|
||||
*
|
||||
* This library 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 2.1 of the
|
||||
* License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#define AARU_NO_FILEIO_REMAP
|
||||
#include "../include/internal.h"
|
||||
#undef AARU_NO_FILEIO_REMAP
|
||||
}
|
||||
|
||||
static FILE *open_temp_test_file()
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
FILE *fp = NULL;
|
||||
return tmpfile_s(&fp) == 0 ? fp : NULL;
|
||||
#else
|
||||
return tmpfile();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(LargeFileIO, SeekTellPastTwoGiB)
|
||||
{
|
||||
FILE *fp = open_temp_test_file();
|
||||
|
||||
if(fp == NULL) GTEST_SKIP() << "Temporary file creation is unavailable on this platform";
|
||||
|
||||
const aaru_off_t target_offset = ((aaru_off_t)3 << 30) + 17;
|
||||
|
||||
ASSERT_EQ(0, aaruf_fseek(fp, target_offset, SEEK_SET));
|
||||
EXPECT_EQ(target_offset, aaruf_ftell(fp));
|
||||
|
||||
ASSERT_NE(EOF, fputc(0x5A, fp));
|
||||
ASSERT_EQ(0, fflush(fp));
|
||||
ASSERT_EQ(0, aaruf_fseek(fp, target_offset, SEEK_SET));
|
||||
|
||||
EXPECT_EQ(target_offset, aaruf_ftell(fp));
|
||||
EXPECT_EQ(0x5A, fgetc(fp));
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -20,9 +20,39 @@
|
||||
#define LIBAARUFORMAT_TOOL_AARUFORMATTOOL_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
#if defined(AARU_USE_WIN32_FILEIO64)
|
||||
#define AARU_FSEEK _fseeki64
|
||||
#define AARU_FTELL _ftelli64
|
||||
#elif defined(AARU_USE_POSIX_FILEIO64)
|
||||
#define AARU_FSEEK fseeko
|
||||
#define AARU_FTELL ftello
|
||||
#else
|
||||
#define AARU_FSEEK fseek
|
||||
#define AARU_FTELL ftell
|
||||
#endif
|
||||
|
||||
typedef int64_t aaru_off_t;
|
||||
|
||||
static inline int aaruf_fseek(FILE *stream, aaru_off_t offset, int origin)
|
||||
{
|
||||
return AARU_FSEEK(stream, offset, origin);
|
||||
}
|
||||
|
||||
static inline aaru_off_t aaruf_ftell(FILE *stream)
|
||||
{
|
||||
return (aaru_off_t)AARU_FTELL(stream);
|
||||
}
|
||||
|
||||
#ifndef AARU_NO_FILEIO_REMAP
|
||||
#define fseek(stream, offset, origin) aaruf_fseek((stream), (aaru_off_t)(offset), (origin))
|
||||
#define ftell(stream) aaruf_ftell((stream))
|
||||
#endif
|
||||
|
||||
int identify(const char *path);
|
||||
int info(const char *path);
|
||||
char *byte_array_to_hex_string(const unsigned char *array, int array_size);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -404,9 +405,9 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
}
|
||||
|
||||
// Get file size
|
||||
fseek(tag_file, 0, SEEK_END);
|
||||
long tag_file_size = ftell(tag_file);
|
||||
fseek(tag_file, 0, SEEK_SET);
|
||||
aaruf_fseek(tag_file, 0, SEEK_END);
|
||||
aaru_off_t tag_file_size = aaruf_ftell(tag_file);
|
||||
aaruf_fseek(tag_file, 0, SEEK_SET);
|
||||
|
||||
if(tag_file_size <= 0)
|
||||
{
|
||||
@@ -419,7 +420,7 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
uint8_t *tag_data = (uint8_t *)malloc((size_t)tag_file_size);
|
||||
if(tag_data == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Cannot allocate memory for media tag data (%ld bytes)\n", tag_file_size);
|
||||
fprintf(stderr, "ERROR: Cannot allocate memory for media tag data (%" PRId64 " bytes)\n", tag_file_size);
|
||||
fclose(tag_file);
|
||||
return -1;
|
||||
}
|
||||
@@ -494,7 +495,7 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
}
|
||||
|
||||
// Seek to index position
|
||||
if(fseek(image_stream, (long)header_v2.indexOffset, SEEK_SET) != 0)
|
||||
if(aaruf_fseek(image_stream, (aaru_off_t)header_v2.indexOffset, SEEK_SET) != 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Cannot seek to index offset %llu: %s\n", (unsigned long long)header_v2.indexOffset,
|
||||
strerror(errno));
|
||||
@@ -604,7 +605,7 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(fseek(image_stream, (long)userdata_ddt->offset, SEEK_SET) != 0)
|
||||
if(aaruf_fseek(image_stream, (aaru_off_t)userdata_ddt->offset, SEEK_SET) != 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Cannot seek to DDT2 offset %llu: %s\n", (unsigned long long)userdata_ddt->offset,
|
||||
strerror(errno));
|
||||
@@ -649,7 +650,7 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
|
||||
printf("Injecting media tag into image...\n");
|
||||
printf(" tag-type: %s (%d) -> DataType %d\n", media_tag_type_to_string(tag_type), tag_type, data_type);
|
||||
printf(" media-tag-file: %s (%ld bytes)\n", media_tag_file, tag_file_size);
|
||||
printf(" media-tag-file: %s (%" PRId64 " bytes)\n", media_tag_file, tag_file_size);
|
||||
printf(" image-file: %s\n", image_file);
|
||||
printf(" index entries: %llu\n", (unsigned long long)index_header.entries);
|
||||
printf(" blockAlignmentShift: %u\n", block_alignment_shift);
|
||||
@@ -691,16 +692,16 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
}
|
||||
|
||||
// Seek to end of file to find where to write the new data block
|
||||
fseek(image_stream, 0, SEEK_END);
|
||||
long current_position = ftell(image_stream);
|
||||
aaruf_fseek(image_stream, 0, SEEK_END);
|
||||
aaru_off_t current_position = aaruf_ftell(image_stream);
|
||||
|
||||
// Align the position
|
||||
uint64_t alignment_mask = (1ULL << block_alignment_shift) - 1;
|
||||
if((uint64_t)current_position & alignment_mask)
|
||||
{
|
||||
uint64_t aligned_position = ((uint64_t)current_position + alignment_mask) & ~alignment_mask;
|
||||
fseek(image_stream, (long)aligned_position, SEEK_SET);
|
||||
current_position = (long)aligned_position;
|
||||
aaruf_fseek(image_stream, (aaru_off_t)aligned_position, SEEK_SET);
|
||||
current_position = (aaru_off_t)aligned_position;
|
||||
}
|
||||
|
||||
uint64_t data_block_position = (uint64_t)current_position;
|
||||
@@ -739,7 +740,7 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf(" Written data block (%zu + %ld bytes)\n", sizeof(BlockHeader), tag_file_size);
|
||||
printf(" Written data block (%zu + %" PRId64 " bytes)\n", sizeof(BlockHeader), tag_file_size);
|
||||
|
||||
// Add new index entry
|
||||
entries = realloc(entries, sizeof(IndexEntry) * (new_entry_count + 1));
|
||||
@@ -761,12 +762,12 @@ int inject_media_tag(const char *tag_type_str, const char *media_tag_file, const
|
||||
(unsigned long long)data_block_position);
|
||||
|
||||
// Align position for index
|
||||
current_position = ftell(image_stream);
|
||||
current_position = aaruf_ftell(image_stream);
|
||||
if((uint64_t)current_position & alignment_mask)
|
||||
{
|
||||
uint64_t aligned_position = ((uint64_t)current_position + alignment_mask) & ~alignment_mask;
|
||||
fseek(image_stream, (long)aligned_position, SEEK_SET);
|
||||
current_position = (long)aligned_position;
|
||||
aaruf_fseek(image_stream, (aaru_off_t)aligned_position, SEEK_SET);
|
||||
current_position = (aaru_off_t)aligned_position;
|
||||
}
|
||||
|
||||
uint64_t new_index_position = (uint64_t)current_position;
|
||||
|
||||
@@ -325,7 +325,7 @@ static int parse_wii_partitions(FILE *iso, uint16_t *part_count, NgcwPartition *
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(fseek(iso, (long)table_offset, SEEK_SET) != 0 || fread(table_data, 1, table_size, iso) != table_size)
|
||||
if(aaruf_fseek(iso, (aaru_off_t)table_offset, SEEK_SET) != 0 || fread(table_data, 1, table_size, iso) != table_size)
|
||||
{
|
||||
free(table_data);
|
||||
free(*parts);
|
||||
@@ -342,7 +342,7 @@ static int parse_wii_partitions(FILE *iso, uint16_t *part_count, NgcwPartition *
|
||||
/* Read ticket */
|
||||
uint8_t ticket[0x2A4];
|
||||
|
||||
if(fseek(iso, (long)part_offset, SEEK_SET) != 0 || fread(ticket, 1, sizeof(ticket), iso) != sizeof(ticket))
|
||||
if(aaruf_fseek(iso, (aaru_off_t)part_offset, SEEK_SET) != 0 || fread(ticket, 1, sizeof(ticket), iso) != sizeof(ticket))
|
||||
{
|
||||
free(table_data);
|
||||
free(*parts);
|
||||
@@ -364,7 +364,7 @@ static int parse_wii_partitions(FILE *iso, uint16_t *part_count, NgcwPartition *
|
||||
/* Read partition header for data offset/size */
|
||||
uint8_t phdr[8];
|
||||
|
||||
if(fseek(iso, (long)(part_offset + 0x2B8), SEEK_SET) != 0 || fread(phdr, 1, 8, iso) != 8)
|
||||
if(aaruf_fseek(iso, (aaru_off_t)(part_offset + 0x2B8), SEEK_SET) != 0 || fread(phdr, 1, 8, iso) != 8)
|
||||
{
|
||||
free(table_data);
|
||||
free(*parts);
|
||||
@@ -1122,7 +1122,7 @@ int convert_ngcw(const char *input_path, const char *output_path)
|
||||
|
||||
if(is_raw)
|
||||
{
|
||||
if(fseek(iso_file, (long)fst_offset, SEEK_SET) == 0 &&
|
||||
if(aaruf_fseek(iso_file, (aaru_off_t)fst_offset, SEEK_SET) == 0 &&
|
||||
fread(fst, 1, fst_size, iso_file) == fst_size)
|
||||
fst_ok = true;
|
||||
}
|
||||
@@ -1202,7 +1202,7 @@ int convert_ngcw(const char *input_path, const char *output_path)
|
||||
/* Read block */
|
||||
if(is_raw)
|
||||
{
|
||||
if(fseek(iso_file, (long)block_off, SEEK_SET) != 0)
|
||||
if(aaruf_fseek(iso_file, (aaru_off_t)block_off, SEEK_SET) != 0)
|
||||
memset(block_buf, 0, block_bytes);
|
||||
else
|
||||
{
|
||||
@@ -1272,7 +1272,7 @@ int convert_ngcw(const char *input_path, const char *output_path)
|
||||
/* Read and decrypt first group to get boot block */
|
||||
uint8_t enc_grp0[WII_GROUP_SIZE];
|
||||
|
||||
if(fseek(iso_file, (long)parts[p].data_offset, SEEK_SET) != 0 ||
|
||||
if(aaruf_fseek(iso_file, (aaru_off_t)parts[p].data_offset, SEEK_SET) != 0 ||
|
||||
fread(enc_grp0, 1, WII_GROUP_SIZE, iso_file) != WII_GROUP_SIZE)
|
||||
continue;
|
||||
|
||||
@@ -1303,7 +1303,7 @@ int convert_ngcw(const char *input_path, const char *output_path)
|
||||
|
||||
uint8_t enc_g[WII_GROUP_SIZE];
|
||||
|
||||
if(fseek(iso_file, (long)disc_off, SEEK_SET) != 0 ||
|
||||
if(aaruf_fseek(iso_file, (aaru_off_t)disc_off, SEEK_SET) != 0 ||
|
||||
fread(enc_g, 1, WII_GROUP_SIZE, iso_file) != WII_GROUP_SIZE)
|
||||
{
|
||||
fst_ok = 0;
|
||||
@@ -1379,7 +1379,7 @@ int convert_ngcw(const char *input_path, const char *output_path)
|
||||
|
||||
uint8_t enc_grp[WII_GROUP_SIZE];
|
||||
|
||||
if(fseek(iso_file, (long)group_disc_off, SEEK_SET) != 0)
|
||||
if(aaruf_fseek(iso_file, (aaru_off_t)group_disc_off, SEEK_SET) != 0)
|
||||
memset(enc_grp, 0, WII_GROUP_SIZE);
|
||||
else
|
||||
{
|
||||
@@ -1570,7 +1570,7 @@ int convert_ngcw(const char *input_path, const char *output_path)
|
||||
|
||||
if(is_raw)
|
||||
{
|
||||
if(fseek(iso_file, (long)aligned_off, SEEK_SET) != 0)
|
||||
if(aaruf_fseek(iso_file, (aaru_off_t)aligned_off, SEEK_SET) != 0)
|
||||
memset(block_buf, 0, block_bytes);
|
||||
else
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -149,7 +150,7 @@ static int32_t iso_read_sector_cb(void *user_data, uint64_t sector, uint8_t *buf
|
||||
|
||||
if(sector >= ctx->total_sectors) return -1;
|
||||
|
||||
if(fseek(ctx->fp, (long)(sector * PS3_SECTOR_SIZE), SEEK_SET) != 0) return -1;
|
||||
if(aaruf_fseek(ctx->fp, (aaru_off_t)(sector * PS3_SECTOR_SIZE), SEEK_SET) != 0) return -1;
|
||||
|
||||
if(fread(buffer, 1, PS3_SECTOR_SIZE, ctx->fp) != PS3_SECTOR_SIZE) return -1;
|
||||
|
||||
@@ -403,14 +404,14 @@ int convert_ps3(const char *input_path, const char *output_path, const char *dis
|
||||
return -1;
|
||||
}
|
||||
|
||||
fseek(iso_fp, 0, SEEK_END);
|
||||
long file_size = ftell(iso_fp);
|
||||
aaruf_fseek(iso_fp, 0, SEEK_END);
|
||||
aaru_off_t file_size = aaruf_ftell(iso_fp);
|
||||
rewind(iso_fp);
|
||||
|
||||
if(file_size <= 0 || file_size % PS3_SECTOR_SIZE != 0)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Invalid ISO file size (%ld bytes, not a multiple of %d)", file_size,
|
||||
PS3_SECTOR_SIZE);
|
||||
snprintf(buffer, sizeof(buffer), "Invalid ISO file size (%" PRId64 " bytes, not a multiple of %d)",
|
||||
file_size, PS3_SECTOR_SIZE);
|
||||
print_error_ps3(buffer);
|
||||
fclose(iso_fp);
|
||||
ps3_free_ird(&ird);
|
||||
@@ -627,7 +628,7 @@ int convert_ps3(const char *input_path, const char *output_path, const char *dis
|
||||
/* Read sector from source */
|
||||
if(is_iso)
|
||||
{
|
||||
if(fseek(iso_fp, (long)(sector * PS3_SECTOR_SIZE), SEEK_SET) != 0 ||
|
||||
if(aaruf_fseek(iso_fp, (aaru_off_t)(sector * PS3_SECTOR_SIZE), SEEK_SET) != 0 ||
|
||||
fread(sector_data, 1, PS3_SECTOR_SIZE, iso_fp) != PS3_SECTOR_SIZE)
|
||||
{
|
||||
printf("\n");
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "ird.h"
|
||||
|
||||
#include "../aaruformattool.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -42,13 +44,13 @@ int32_t ps3_parse_ird(const char *path, IrdFile *ird)
|
||||
if(fp == NULL) return -2;
|
||||
|
||||
/* Get file size */
|
||||
if(fseek(fp, 0, SEEK_END) != 0)
|
||||
if(aaruf_fseek(fp, 0, SEEK_END) != 0)
|
||||
{
|
||||
fclose(fp);
|
||||
return -3;
|
||||
}
|
||||
|
||||
long file_size = ftell(fp);
|
||||
aaru_off_t file_size = aaruf_ftell(fp);
|
||||
|
||||
if(file_size <= 0)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "reader.h"
|
||||
|
||||
#include "../aaruformattool.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -32,7 +34,7 @@ static int wux_init(WiiuReader *reader)
|
||||
{
|
||||
WuxHeader hdr;
|
||||
|
||||
if(fseek(reader->fp, 0, SEEK_SET) != 0) return -1;
|
||||
if(aaruf_fseek(reader->fp, 0, SEEK_SET) != 0) return -1;
|
||||
|
||||
if(fread(&hdr, 1, sizeof(hdr), reader->fp) != sizeof(hdr)) return -1;
|
||||
|
||||
@@ -58,7 +60,7 @@ static int wux_init(WiiuReader *reader)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(fseek(reader->fp, 0x20, SEEK_SET) != 0)
|
||||
if(aaruf_fseek(reader->fp, 0x20, SEEK_SET) != 0)
|
||||
{
|
||||
free(reader->wux_index);
|
||||
reader->wux_index = NULL;
|
||||
@@ -98,7 +100,7 @@ int wiiu_reader_open(const char *path, WiiuReader *reader)
|
||||
/* Fallback: raw WUD — get file size */
|
||||
reader->is_wux = 0;
|
||||
|
||||
if(fseek(reader->fp, 0, SEEK_END) != 0)
|
||||
if(aaruf_fseek(reader->fp, 0, SEEK_END) != 0)
|
||||
{
|
||||
fprintf(stderr, "Error: cannot determine file size for %s\n", path);
|
||||
fclose(reader->fp);
|
||||
@@ -106,7 +108,7 @@ int wiiu_reader_open(const char *path, WiiuReader *reader)
|
||||
return -1;
|
||||
}
|
||||
|
||||
long file_size = ftell(reader->fp);
|
||||
aaru_off_t file_size = aaruf_ftell(reader->fp);
|
||||
|
||||
if(file_size <= 0)
|
||||
{
|
||||
@@ -143,7 +145,7 @@ int64_t wiiu_reader_read_at(WiiuReader *reader, void *buf, size_t count, uint64_
|
||||
if(!reader->is_wux)
|
||||
{
|
||||
/* Raw WUD: direct seek + read */
|
||||
if(fseek(reader->fp, (long)offset, SEEK_SET) != 0) return -1;
|
||||
if(aaruf_fseek(reader->fp, (aaru_off_t)offset, SEEK_SET) != 0) return -1;
|
||||
|
||||
size_t n = fread(buf, 1, count, reader->fp);
|
||||
|
||||
@@ -172,7 +174,7 @@ int64_t wiiu_reader_read_at(WiiuReader *reader, void *buf, size_t count, uint64_
|
||||
|
||||
if(chunk > count - done) chunk = count - done;
|
||||
|
||||
if(fseek(reader->fp, (long)file_offset, SEEK_SET) != 0) break;
|
||||
if(aaruf_fseek(reader->fp, (aaru_off_t)file_offset, SEEK_SET) != 0) break;
|
||||
|
||||
size_t n = fread(out + done, 1, chunk, reader->fp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user