mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Add write functionality for sectors and implement block closing logic
This commit is contained in:
16
src/close.c
16
src/close.c
@@ -26,10 +26,12 @@
|
||||
|
||||
#include <aaruformat.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
int aaruf_close(void *context)
|
||||
{
|
||||
int i = 0;
|
||||
mediaTagEntry *mediaTag = NULL;
|
||||
int i = 0;
|
||||
mediaTagEntry *mediaTag = NULL;
|
||||
mediaTagEntry *tmpMediaTag = NULL;
|
||||
|
||||
if(context == NULL)
|
||||
@@ -55,9 +57,17 @@ int aaruf_close(void *context)
|
||||
{
|
||||
fclose(ctx->imageStream);
|
||||
ctx->imageStream = NULL;
|
||||
errno = AARUF_ERROR_CANNOT_WRITE_HEADER;
|
||||
errno = AARUF_ERROR_CANNOT_WRITE_HEADER;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Close current block first
|
||||
if(ctx->writingBuffer != NULL)
|
||||
{
|
||||
int error = aaruf_close_current_block(ctx);
|
||||
|
||||
if(error != AARUF_STATUS_OK) return error;
|
||||
}
|
||||
}
|
||||
|
||||
// This may do nothing if imageStream is NULL, but as the behaviour is undefined, better sure than sorry
|
||||
|
||||
Reference in New Issue
Block a user