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:
@@ -19,6 +19,7 @@
|
||||
#ifndef LIBAARUFORMAT_CONTEXT_H
|
||||
#define LIBAARUFORMAT_CONTEXT_H
|
||||
|
||||
#include "crc64.h"
|
||||
#include "lru.h"
|
||||
#include "structs.h"
|
||||
|
||||
@@ -116,6 +117,11 @@ typedef struct aaruformatContext
|
||||
uint16_t *cachedSecondaryDdtSmall;
|
||||
uint32_t *cachedSecondaryDdtBig;
|
||||
bool isWriting;
|
||||
BlockHeader currentBlockHeader;
|
||||
uint8_t *writingBuffer;
|
||||
int currentBlockOffset;
|
||||
crc64_ctx *crc64Context;
|
||||
int writingBufferPosition;
|
||||
} aaruformatContext;
|
||||
|
||||
typedef struct DumpHardwareEntriesWithData
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#ifndef LIBAARUFORMAT_CRC64_H
|
||||
#define LIBAARUFORMAT_CRC64_H
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -65,7 +65,8 @@ AARU_EXPORT void *AARU_CALL aaruf_open(const char *filepath);
|
||||
AARU_EXPORT void *AARU_CALL aaruf_create(const char *filepath, uint32_t mediaType, uint32_t sectorSize,
|
||||
uint64_t userSectors, uint64_t negativeSectors, uint64_t overflowSectors,
|
||||
const char *options, const uint8_t *applicationName,
|
||||
uint8_t applicationMajorVersion, uint8_t applicationMinorVersion);
|
||||
uint8_t applicationNameLength, uint8_t applicationMajorVersion,
|
||||
uint8_t applicationMinorVersion);
|
||||
|
||||
AARU_EXPORT int AARU_CALL aaruf_close(void *context);
|
||||
|
||||
@@ -82,6 +83,9 @@ AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void *context, uint64_t sectorAd
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, uint64_t sectorAddress, uint8_t *data,
|
||||
uint32_t *length);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sectorAddress, uint8_t *data,
|
||||
uint8_t sectorStatus, uint32_t length);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_verify_image(void *context);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL aaruf_cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length);
|
||||
|
||||
@@ -19,27 +19,30 @@
|
||||
#ifndef LIBAARUFORMAT_ERRORS_H
|
||||
#define LIBAARUFORMAT_ERRORS_H
|
||||
|
||||
#define AARUF_ERROR_NOT_AARUFORMAT -1
|
||||
#define AARUF_ERROR_FILE_TOO_SMALL -2
|
||||
#define AARUF_ERROR_INCOMPATIBLE_VERSION -3
|
||||
#define AARUF_ERROR_CANNOT_READ_INDEX -4
|
||||
#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS -5
|
||||
#define AARUF_ERROR_CANNOT_READ_HEADER -6
|
||||
#define AARUF_ERROR_CANNOT_READ_BLOCK -7
|
||||
#define AARUF_ERROR_UNSUPPORTED_COMPRESSION -8
|
||||
#define AARUF_ERROR_NOT_ENOUGH_MEMORY -9
|
||||
#define AARUF_ERROR_BUFFER_TOO_SMALL -10
|
||||
#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT -11
|
||||
#define AARUF_ERROR_INCORRECT_MEDIA_TYPE -12
|
||||
#define AARUF_ERROR_TRACK_NOT_FOUND -13
|
||||
#define AARUF_ERROR_REACHED_UNREACHABLE_CODE -14
|
||||
#define AARUF_ERROR_INVALID_TRACK_FORMAT -15
|
||||
#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT -16
|
||||
#define AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK -17
|
||||
#define AARUF_ERROR_INVALID_BLOCK_CRC -18
|
||||
#define AARUF_ERROR_CANNOT_CREATE_FILE -19
|
||||
#define AARUF_ERROR_INVALID_APP_NAME_LENGTH -20
|
||||
#define AARUF_ERROR_CANNOT_WRITE_HEADER -21
|
||||
#define AARUF_ERROR_NOT_AARUFORMAT -1
|
||||
#define AARUF_ERROR_FILE_TOO_SMALL -2
|
||||
#define AARUF_ERROR_INCOMPATIBLE_VERSION -3
|
||||
#define AARUF_ERROR_CANNOT_READ_INDEX -4
|
||||
#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS -5
|
||||
#define AARUF_ERROR_CANNOT_READ_HEADER -6
|
||||
#define AARUF_ERROR_CANNOT_READ_BLOCK -7
|
||||
#define AARUF_ERROR_UNSUPPORTED_COMPRESSION -8
|
||||
#define AARUF_ERROR_NOT_ENOUGH_MEMORY -9
|
||||
#define AARUF_ERROR_BUFFER_TOO_SMALL -10
|
||||
#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT -11
|
||||
#define AARUF_ERROR_INCORRECT_MEDIA_TYPE -12
|
||||
#define AARUF_ERROR_TRACK_NOT_FOUND -13
|
||||
#define AARUF_ERROR_REACHED_UNREACHABLE_CODE -14
|
||||
#define AARUF_ERROR_INVALID_TRACK_FORMAT -15
|
||||
#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT -16
|
||||
#define AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK -17
|
||||
#define AARUF_ERROR_INVALID_BLOCK_CRC -18
|
||||
#define AARUF_ERROR_CANNOT_CREATE_FILE -19
|
||||
#define AARUF_ERROR_INVALID_APP_NAME_LENGTH -20
|
||||
#define AARUF_ERROR_CANNOT_WRITE_HEADER -21
|
||||
#define AARUF_READ_ONLY -22
|
||||
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER -23
|
||||
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA -24
|
||||
|
||||
#define AARUF_STATUS_OK 0
|
||||
#define AARUF_STATUS_SECTOR_NOT_DUMPED 1
|
||||
|
||||
Reference in New Issue
Block a user