Implement creating AaruFormat image and writing header.

This commit is contained in:
2025-08-07 15:43:35 +01:00
parent 676a87d25b
commit 3b012797cb
11 changed files with 354 additions and 2 deletions

View File

@@ -47,6 +47,19 @@ int aaruf_close(void *context)
return -1;
}
if(ctx->isWriting)
{
// Write the header at the beginning of the file
fseek(ctx->imageStream, 0, SEEK_SET);
if(fwrite(&ctx->header, sizeof(AaruHeaderV2), 1, ctx->imageStream) != 1)
{
fclose(ctx->imageStream);
ctx->imageStream = NULL;
errno = AARUF_ERROR_CANNOT_WRITE_HEADER;
return -1;
}
}
// This may do nothing if imageStream is NULL, but as the behaviour is undefined, better sure than sorry
if(ctx->imageStream != NULL)
{