mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2026-04-06 06:01:06 +00:00
refactor: split close.c into reader/writer
Separate writer finalization from resource cleanup in close.c to enable a future reader-only library target (aaruformatread). close_write.c contains all write_* helpers and aaruf_finalize_write(). close.c retains aaruf_close() with cleanup only, dispatching writer finalization via a function pointer set by aaruf_create()/aaruf_open(). Zero behavioral change — same tests pass, same error semantics.
This commit is contained in:
@@ -196,6 +196,7 @@ add_library(aaruformat
|
||||
src/open.c
|
||||
include/aaruformat/context.h
|
||||
src/close.c
|
||||
src/close_write.c
|
||||
include/aaruformat/errors.h
|
||||
src/read.c
|
||||
include/aaruformat/crc64.h
|
||||
|
||||
@@ -296,6 +296,7 @@ typedef struct aaruformat_context
|
||||
bool rewinded; ///< True if stream has been rewound after open (write path).
|
||||
bool writing_long; ///< True if writing long sectors
|
||||
bool block_zero_written; ///< True if block zero has been written (writing path).
|
||||
int32_t (*finalize_write)(struct aaruformat_context *ctx); ///< Writer finalization hook (NULL for reader).
|
||||
|
||||
/* Options */
|
||||
uint32_t lzma_dict_size; ///< LZMA dictionary size (writing path).
|
||||
|
||||
@@ -63,6 +63,7 @@ bool set_ddt_tape(aaruformat_context *ctx, uint64_t sector_address, uint64_t
|
||||
aaru_options parse_options(const char *options, bool *table_shift_found);
|
||||
uint64_t get_filetime_uint64();
|
||||
int32_t aaruf_close_current_block(aaruformat_context *ctx);
|
||||
int32_t aaruf_finalize_write(aaruformat_context *ctx);
|
||||
int compare_extents(const void *a, const void *b);
|
||||
void generate_random_bytes(uint8_t *buffer, size_t length);
|
||||
|
||||
|
||||
5388
src/close.c
5388
src/close.c
File diff suppressed because it is too large
Load Diff
5395
src/close_write.c
Normal file
5395
src/close_write.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -566,7 +566,8 @@ AARU_EXPORT void *AARU_CALL aaruf_create(const char *filepath, const uint32_t me
|
||||
}
|
||||
|
||||
// Is writing
|
||||
ctx->is_writing = true;
|
||||
ctx->is_writing = true;
|
||||
ctx->finalize_write = aaruf_finalize_write;
|
||||
|
||||
// Initialize dirty flags - all true by default for new images
|
||||
ctx->dirty_secondary_ddt = true;
|
||||
|
||||
@@ -714,7 +714,8 @@ AARU_EXPORT void *AARU_CALL aaruf_open(const char *filepath, const bool resume_m
|
||||
ctx->rewinded = true;
|
||||
|
||||
// Is writing
|
||||
ctx->is_writing = true;
|
||||
ctx->is_writing = true;
|
||||
ctx->finalize_write = aaruf_finalize_write;
|
||||
|
||||
TRACE("Exiting aaruf_open() = %p", ctx);
|
||||
// Return context
|
||||
|
||||
Reference in New Issue
Block a user