mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
For DiscImageChef format, calculate image size without headers and sector size (biggest found), by indexing all data blocks.
This commit is contained in:
@@ -233,9 +233,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
// TODO: Non-deduplicatable sector tags are data blocks
|
// TODO: Non-deduplicatable sector tags are data blocks
|
||||||
case BlockType.DataBlock:
|
case BlockType.DataBlock:
|
||||||
// NOP block, skip
|
// NOP block, skip
|
||||||
if(entry.dataType == DataType.NoData ||
|
if(entry.dataType == DataType.NoData) break;
|
||||||
// Unused, skip
|
|
||||||
entry.dataType == DataType.UserData) break;
|
|
||||||
|
|
||||||
imageStream.Position = (long)entry.offset;
|
imageStream.Position = (long)entry.offset;
|
||||||
|
|
||||||
@@ -248,6 +246,14 @@ namespace DiscImageChef.DiscImages
|
|||||||
Marshal.FreeHGlobal(structurePointer);
|
Marshal.FreeHGlobal(structurePointer);
|
||||||
imageInfo.ImageSize += blockHeader.cmpLength;
|
imageInfo.ImageSize += blockHeader.cmpLength;
|
||||||
|
|
||||||
|
// Unused, skip
|
||||||
|
if(entry.dataType == DataType.UserData)
|
||||||
|
{
|
||||||
|
if(blockHeader.sectorSize > imageInfo.SectorSize)
|
||||||
|
imageInfo.SectorSize = blockHeader.sectorSize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(blockHeader.identifier != entry.blockType)
|
if(blockHeader.identifier != entry.blockType)
|
||||||
{
|
{
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
@@ -568,18 +574,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
if(!foundUserDataDdt) throw new ImageNotSupportedException("Could not find user data deduplication table.");
|
if(!foundUserDataDdt) throw new ImageNotSupportedException("Could not find user data deduplication table.");
|
||||||
|
|
||||||
// TODO: Sector size!
|
|
||||||
imageInfo.SectorSize = 512;
|
|
||||||
|
|
||||||
imageInfo.CreationTime = DateTime.FromFileTimeUtc(header.creationTime);
|
imageInfo.CreationTime = DateTime.FromFileTimeUtc(header.creationTime);
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Image created on", imageInfo.CreationTime);
|
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Image created on", imageInfo.CreationTime);
|
||||||
imageInfo.LastModificationTime = DateTime.FromFileTimeUtc(header.lastWrittenTime);
|
imageInfo.LastModificationTime = DateTime.FromFileTimeUtc(header.lastWrittenTime);
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Image last written on",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Image last written on",
|
||||||
imageInfo.LastModificationTime);
|
imageInfo.LastModificationTime);
|
||||||
|
|
||||||
// TODO: Calculate
|
|
||||||
//imageInfo.ImageSize = qHdr.size;
|
|
||||||
|
|
||||||
if(geometryBlock.identifier != BlockType.GeometryBlock && imageInfo.XmlMediaType == XmlMediaType.BlockMedia)
|
if(geometryBlock.identifier != BlockType.GeometryBlock && imageInfo.XmlMediaType == XmlMediaType.BlockMedia)
|
||||||
{
|
{
|
||||||
imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63);
|
imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63);
|
||||||
@@ -964,6 +964,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
Crc64Context.Data(blockStream.ToArray(), out byte[] cmpCrc64);
|
Crc64Context.Data(blockStream.ToArray(), out byte[] cmpCrc64);
|
||||||
currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64, 0);
|
currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64, 0);
|
||||||
|
|
||||||
|
index.Add(new IndexEntry
|
||||||
|
{
|
||||||
|
blockType = BlockType.DataBlock,
|
||||||
|
dataType = DataType.UserData,
|
||||||
|
offset = (ulong)imageStream.Position
|
||||||
|
});
|
||||||
|
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(currentBlockHeader));
|
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(currentBlockHeader));
|
||||||
structureBytes = new byte[Marshal.SizeOf(currentBlockHeader)];
|
structureBytes = new byte[Marshal.SizeOf(currentBlockHeader)];
|
||||||
Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
||||||
@@ -1078,6 +1085,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
Crc64Context.Data(blockStream.ToArray(), out byte[] cmpCrc64);
|
Crc64Context.Data(blockStream.ToArray(), out byte[] cmpCrc64);
|
||||||
currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64, 0);
|
currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64, 0);
|
||||||
|
|
||||||
|
index.Add(new IndexEntry
|
||||||
|
{
|
||||||
|
blockType = BlockType.DataBlock,
|
||||||
|
dataType = DataType.UserData,
|
||||||
|
offset = (ulong)imageStream.Position
|
||||||
|
});
|
||||||
|
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(currentBlockHeader));
|
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(currentBlockHeader));
|
||||||
structureBytes = new byte[Marshal.SizeOf(currentBlockHeader)];
|
structureBytes = new byte[Marshal.SizeOf(currentBlockHeader)];
|
||||||
Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user