mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Seek to all indexed entries.
This commit is contained in:
50
src/open.c
50
src/open.c
@@ -36,6 +36,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
// TODO: Check CRC64 on structures
|
// TODO: Check CRC64 on structures
|
||||||
// TODO: ImageInfo
|
// TODO: ImageInfo
|
||||||
@@ -47,6 +48,7 @@ void *open(const char *filepath)
|
|||||||
long pos;
|
long pos;
|
||||||
IndexHeader idxHeader;
|
IndexHeader idxHeader;
|
||||||
IndexEntry *idxEntries;
|
IndexEntry *idxEntries;
|
||||||
|
uint64_t ImageSize; // TODO: This should be in ImageInfo
|
||||||
|
|
||||||
memset(ctx, 0, sizeof(dicformatContext));
|
memset(ctx, 0, sizeof(dicformatContext));
|
||||||
|
|
||||||
@@ -159,6 +161,54 @@ void *open(const char *filepath)
|
|||||||
idxEntries[i].offset);
|
idxEntries[i].offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool foundUserDataDdt = false;
|
||||||
|
for(int i = 0; i < idxHeader.entries; i++)
|
||||||
|
{
|
||||||
|
pos = fseek(ctx->imageStream, idxEntries[i].offset, SEEK_SET);
|
||||||
|
|
||||||
|
if(pos < 0 || ftell(ctx->imageStream) != idxEntries[i].offset)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"libdicformat: Could not seek to %"PRIu64" as indicated by index entry %d, continuing...",
|
||||||
|
idxEntries[i].offset,
|
||||||
|
i);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(idxEntries[i].blockType)
|
||||||
|
{
|
||||||
|
case DataBlock:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case DeDuplicationTable:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case GeometryBlock:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case MetadataBlock:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case TracksBlock:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case CicmBlock:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
case DumpHardwareBlock:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,
|
||||||
|
"libdicformat: Unhandled block type %4s with data type %4s is indexed to be at %"PRIu64"",
|
||||||
|
(char *)&idxEntries[i].blockType,
|
||||||
|
(char *)&idxEntries[i].dataType,
|
||||||
|
idxEntries[i].offset);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx->magic = DIC_MAGIC;
|
ctx->magic = DIC_MAGIC;
|
||||||
ctx->libraryMajorVersion = LIBDICFORMAT_MAJOR_VERSION;
|
ctx->libraryMajorVersion = LIBDICFORMAT_MAJOR_VERSION;
|
||||||
ctx->libraryMinorVersion = LIBDICFORMAT_MINOR_VERSION;
|
ctx->libraryMinorVersion = LIBDICFORMAT_MINOR_VERSION;
|
||||||
|
|||||||
Reference in New Issue
Block a user