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:
Kevin Bortis
2026-04-02 08:32:10 +02:00
parent 62202a5c29
commit d8ff7b4a28
7 changed files with 5419 additions and 5373 deletions

View File

@@ -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).

View File

@@ -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);