mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 11:14:39 +00:00
Add support for negative sector addresses in read/write functions
This commit is contained in:
@@ -106,8 +106,8 @@ int cli_compare(const char *path1, const char *path2)
|
||||
buffer1_length = ctx1->imageInfo.SectorSize;
|
||||
buffer2_length = ctx2->imageInfo.SectorSize;
|
||||
|
||||
read_result1 = aaruf_read_sector(ctx1, sector, buffer1, &buffer1_length);
|
||||
read_result2 = aaruf_read_sector(ctx2, sector, buffer2, &buffer2_length);
|
||||
read_result1 = aaruf_read_sector(ctx1, sector, false, buffer1, &buffer1_length);
|
||||
read_result2 = aaruf_read_sector(ctx2, sector, false, buffer2, &buffer2_length);
|
||||
|
||||
// Handle read errors or missing sectors
|
||||
const bool sector1_available = read_result1 == AARUF_STATUS_OK;
|
||||
|
||||
@@ -489,7 +489,7 @@ int compare(const char *path1, const char *path2)
|
||||
tb_printf(2, height - 5, TB_WHITE | TB_BOLD, TB_BLUE, "Comparing sector %llu of %llu", i + 1, sectors);
|
||||
draw_progress_bar(height - 4, i * 100 / sectors);
|
||||
|
||||
errno = aaruf_read_sector(ctx1, i, buffer1, §orSize);
|
||||
errno = aaruf_read_sector(ctx1, i, false, buffer1, §orSize);
|
||||
if(errno != AARUF_STATUS_OK && errno != AARUF_STATUS_SECTOR_NOT_DUMPED)
|
||||
{
|
||||
tb_printf(2, lr++, TB_RED | TB_BOLD, TB_BLUE, "Error reading sector %llu: %s", i, errno);
|
||||
@@ -497,7 +497,7 @@ int compare(const char *path1, const char *path2)
|
||||
continue;
|
||||
}
|
||||
|
||||
errno = aaruf_read_sector(ctx2, i, buffer2, §orSize);
|
||||
errno = aaruf_read_sector(ctx2, i, false, buffer2, §orSize);
|
||||
if(errno != AARUF_STATUS_OK && errno != AARUF_STATUS_SECTOR_NOT_DUMPED)
|
||||
{
|
||||
tb_printf(2, rr++, TB_RED | TB_BOLD, TB_BLUE, "Error reading sector %llu: %s", i, errno);
|
||||
|
||||
@@ -93,7 +93,7 @@ int convert(const char *input_path, const char *output_path)
|
||||
}
|
||||
|
||||
// Read sector from input
|
||||
res = aaruf_read_sector(input_ctx, sector, sector_data, &read_length);
|
||||
res = aaruf_read_sector(input_ctx, sector, false, sector_data, &read_length);
|
||||
if(res != AARUF_STATUS_OK)
|
||||
{
|
||||
printf("\nError %d when reading sector %llu from input image.\n", res, (unsigned long long)sector);
|
||||
@@ -101,7 +101,7 @@ int convert(const char *input_path, const char *output_path)
|
||||
}
|
||||
|
||||
// Write sector to output
|
||||
res = aaruf_write_sector(output_ctx, sector, sector_data, SectorStatusDumped, read_length);
|
||||
res = aaruf_write_sector(output_ctx, sector, false, sector_data, SectorStatusDumped, read_length);
|
||||
if(res != AARUF_STATUS_OK)
|
||||
{
|
||||
printf("\nError %d when writing sector %llu to output image.\n", res, (unsigned long long)sector);
|
||||
|
||||
@@ -39,7 +39,7 @@ int read(const unsigned long long sector_no, const char *path)
|
||||
return errno;
|
||||
}
|
||||
|
||||
res = aaruf_read_sector(ctx, sector_no, NULL, &length);
|
||||
res = aaruf_read_sector(ctx, sector_no, false, NULL, &length);
|
||||
|
||||
if(res != AARUF_STATUS_OK && res != AARUF_ERROR_BUFFER_TOO_SMALL)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ int read(const unsigned long long sector_no, const char *path)
|
||||
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
res = aaruf_read_sector(ctx, sector_no, data, &length);
|
||||
res = aaruf_read_sector(ctx, sector_no, false, data, &length);
|
||||
|
||||
if(res != AARUF_STATUS_OK)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ int read_long(const unsigned long long sector_no, const char *path)
|
||||
return errno;
|
||||
}
|
||||
|
||||
res = aaruf_read_sector_long(ctx, sector_no, NULL, &length);
|
||||
res = aaruf_read_sector_long(ctx, sector_no, false, NULL, &length);
|
||||
|
||||
if(res != AARUF_STATUS_OK && res != AARUF_ERROR_BUFFER_TOO_SMALL)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ int read_long(const unsigned long long sector_no, const char *path)
|
||||
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
res = aaruf_read_sector_long(ctx, sector_no, data, &length);
|
||||
res = aaruf_read_sector_long(ctx, sector_no, false, data, &length);
|
||||
|
||||
if(res != AARUF_STATUS_OK)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ int verify_sectors(const char *path)
|
||||
for(uint64_t s = 0; s < ctx->imageInfo.Sectors; s++)
|
||||
{
|
||||
printf("\rVerifying sector %llu...", s);
|
||||
res = aaruf_read_sector_long(ctx, s, buffer, &buffer_len);
|
||||
res = aaruf_read_sector_long(ctx, s, buffer, false, &buffer_len);
|
||||
|
||||
if(res != AARUF_STATUS_OK)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user