Use Aaru Metadata instead of CICM Metadata.

This commit is contained in:
2022-12-15 22:21:07 +00:00
parent 031f871a2d
commit cfbcde35f5
346 changed files with 11377 additions and 8653 deletions

View File

@@ -34,8 +34,8 @@ using System;
using System.Collections.Generic;
using System.Threading;
using Aaru.Checksums;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Interfaces;
using Schemas;
namespace Aaru.Core;
@@ -380,148 +380,101 @@ public sealed class Checksum
/// <summary>Finishes the checksums</summary>
/// <returns>Returns the checksum results</returns>
public List<ChecksumType> End()
public List<CommonTypes.AaruMetadata.Checksum> End()
{
List<ChecksumType> chks = new();
List<CommonTypes.AaruMetadata.Checksum> chks = new();
ChecksumType chk;
if(_enabled.HasFlag(EnableChecksum.All))
{
chk = new ChecksumType
if(_enabled.HasFlag(EnableChecksum.Adler32))
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.adler32,
Type = ChecksumType.Adler32,
Value = _adler32Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Crc16))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.crc16,
Type = ChecksumType.CRC16,
Value = _crc16Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Crc32))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.crc32,
Type = ChecksumType.CRC32,
Value = _crc32Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Crc64))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.crc64,
Type = ChecksumType.CRC64,
Value = _crc64Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Md5))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.md5,
Type = ChecksumType.Md5,
Value = _md5Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Sha1))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha1,
Type = ChecksumType.Sha1,
Value = _sha1Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Sha256))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha256,
Type = ChecksumType.Sha256,
Value = _sha256Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Sha384))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha384,
Type = ChecksumType.Sha384,
Value = _sha384Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Sha512))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha512,
Type = ChecksumType.Sha512,
Value = _sha512Ctx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.SpamSum))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.spamsum,
Type = ChecksumType.SpamSum,
Value = _ssCtx.End()
};
chks.Add(chk);
}
});
if(_enabled.HasFlag(EnableChecksum.Fletcher16))
{
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.fletcher16,
Type = ChecksumType.Fletcher16,
Value = _f16Ctx.End()
};
chks.Add(chk);
}
});
if(!_enabled.HasFlag(EnableChecksum.Fletcher32))
return chks;
chk = new ChecksumType
chks.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.fletcher32,
Type = ChecksumType.Fletcher32,
Value = _f32Ctx.End()
};
chks.Add(chk);
});
return chks;
}
internal static List<ChecksumType> GetChecksums(byte[] data, EnableChecksum enabled = EnableChecksum.All)
internal static List<CommonTypes.AaruMetadata.Checksum> GetChecksums(
byte[] data, EnableChecksum enabled = EnableChecksum.All)
{
IChecksum adler32CtxData = null;
IChecksum crc16CtxData = null;
@@ -718,140 +671,93 @@ public sealed class Checksum
f16ThreadData.IsAlive ||
f32ThreadData.IsAlive) {}
List<ChecksumType> dataChecksums = new();
ChecksumType chk;
List<CommonTypes.AaruMetadata.Checksum> dataChecksums = new();
if(enabled.HasFlag(EnableChecksum.Adler32))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.adler32,
Type = ChecksumType.Adler32,
Value = adler32CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Crc16))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.crc16,
Type = ChecksumType.CRC16,
Value = crc16CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Crc32))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.crc32,
Type = ChecksumType.CRC32,
Value = crc32CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Crc64))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.crc64,
Type = ChecksumType.CRC64,
Value = crc64CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Md5))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.md5,
Type = ChecksumType.Md5,
Value = md5CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Sha1))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha1,
Type = ChecksumType.Sha1,
Value = sha1CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Sha256))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha256,
Type = ChecksumType.Sha256,
Value = sha256CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Sha384))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha384,
Type = ChecksumType.Sha384,
Value = sha384CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Sha512))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.sha512,
Type = ChecksumType.Sha512,
Value = sha512CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.SpamSum))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.spamsum,
Type = ChecksumType.SpamSum,
Value = ssctxData.End()
};
dataChecksums.Add(chk);
}
});
if(enabled.HasFlag(EnableChecksum.Fletcher16))
{
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.fletcher16,
Type = ChecksumType.Fletcher16,
Value = f16CtxData.End()
};
dataChecksums.Add(chk);
}
});
if(!enabled.HasFlag(EnableChecksum.Fletcher32))
return dataChecksums;
chk = new ChecksumType
dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum
{
type = ChecksumTypeType.fletcher32,
Type = ChecksumType.Fletcher32,
Value = f32CtxData.End()
};
dataChecksums.Add(chk);
});
return dataChecksums;
}

View File

@@ -34,8 +34,10 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
@@ -44,7 +46,6 @@ using Aaru.Core.Graphics;
using Aaru.Core.Logging;
using Aaru.Decoders.ATA;
using Aaru.Decoders.PCMCIA;
using Schemas;
using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify;
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -175,8 +176,8 @@ public partial class Dump
bool removable = !_dev.IsCompactFlash &&
ataId.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit.Removable);
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(ataReader.IsLba, removable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
@@ -595,7 +596,7 @@ public partial class Dump
if(!error || recoveredError)
{
mhddLog.Write(currentBlock, duration, 1);
mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, currentSpeed * 1024);
DateTime writeStart = DateTime.Now;
@@ -612,7 +613,7 @@ public partial class Dump
else
{
_resume.BadBlocks.Add(currentBlock);
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration, 1);
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
ibgLog.Write(currentBlock, 0);
DateTime writeStart = DateTime.Now;
@@ -679,12 +680,12 @@ public partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputFormat.SetMetadata(metadata))
if(!outputFormat.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputFormat.ErrorMessage);
if(_preSidecar != null)
outputFormat.SetCicmMetadata(_preSidecar);
outputFormat.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
@@ -745,14 +746,14 @@ public partial class Dump
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus;
CICMMetadataType sidecar = _sidecarClass.Create();
Metadata sidecar = _sidecarClass.Create();
if(!_aborted)
{
if(_preSidecar != null)
{
_preSidecar.BlockMedia = sidecar.BlockMedia;
sidecar = _preSidecar;
_preSidecar.BlockMedias = sidecar.BlockMedias;
sidecar = _preSidecar;
}
if(_dev.IsUsb &&
@@ -761,15 +762,15 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Reading_USB_descriptors);
UpdateStatus?.Invoke(Localization.Core.Reading_USB_descriptors);
sidecar.BlockMedia[0].USB = new USBType
sidecar.BlockMedias[0].Usb = new Usb
{
ProductID = _dev.UsbProductId,
VendorID = _dev.UsbVendorId,
Descriptors = new DumpType
Descriptors = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)_dev.UsbDescriptors.Length,
Checksums = Checksum.GetChecksums(_dev.UsbDescriptors).ToArray()
Checksums = Checksum.GetChecksums(_dev.UsbDescriptors)
}
};
}
@@ -780,13 +781,13 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Reading_PCMCIA_CIS);
UpdateStatus?.Invoke(Localization.Core.Reading_PCMCIA_CIS);
sidecar.BlockMedia[0].PCMCIA = new PCMCIAType
sidecar.BlockMedias[0].Pcmcia = new Pcmcia
{
CIS = new DumpType
Cis = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)_dev.Cis.Length,
Checksums = Checksum.GetChecksums(_dev.Cis).ToArray()
Checksums = Checksum.GetChecksums(_dev.Cis)
}
};
@@ -804,12 +805,10 @@ public partial class Dump
if(manufacturerId != null)
{
sidecar.BlockMedia[0].PCMCIA.ManufacturerCode =
sidecar.BlockMedias[0].Pcmcia.ManufacturerCode =
manufacturerId.ManufacturerID;
sidecar.BlockMedia[0].PCMCIA.CardCode = manufacturerId.CardID;
sidecar.BlockMedia[0].PCMCIA.ManufacturerCodeSpecified = true;
sidecar.BlockMedia[0].PCMCIA.CardCodeSpecified = true;
sidecar.BlockMedias[0].Pcmcia.CardCode = manufacturerId.CardID;
}
break;
@@ -818,14 +817,14 @@ public partial class Dump
if(version != null)
{
sidecar.BlockMedia[0].PCMCIA.Manufacturer = version.Manufacturer;
sidecar.BlockMedia[0].PCMCIA.ProductName = version.Product;
sidecar.BlockMedias[0].Pcmcia.Manufacturer = version.Manufacturer;
sidecar.BlockMedias[0].Pcmcia.ProductName = version.Product;
sidecar.BlockMedia[0].PCMCIA.Compliance =
sidecar.BlockMedias[0].Pcmcia.Compliance =
$"{version.MajorVersion}.{version.MinorVersion}";
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation =
version.AdditionalInformation;
sidecar.BlockMedias[0].Pcmcia.AdditionalInformation =
new List<string>(version.AdditionalInformation);
}
break;
@@ -835,13 +834,13 @@ public partial class Dump
if(_private)
DeviceReport.ClearIdentify(ataIdentify);
sidecar.BlockMedia[0].ATA = new ATAType
sidecar.BlockMedias[0].ATA = new ATA
{
Identify = new DumpType
Identify = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
Checksums = Checksum.GetChecksums(cmdBuf)
}
};
@@ -864,8 +863,8 @@ public partial class Dump
List<(ulong start, string type)> filesystems = new();
if(sidecar.BlockMedia[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
if(sidecar.BlockMedias[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedias[0].FileSystemInformation
where partition.FileSystems != null
from fileSystem in partition.FileSystems
select (partition.StartSector, fileSystem.Type));
@@ -886,39 +885,40 @@ public partial class Dump
(string type, string subType) = CommonTypes.Metadata.MediaType.MediaTypeToString(mediaType);
sidecar.BlockMedia[0].DiskType = type;
sidecar.BlockMedia[0].DiskSubType = subType;
sidecar.BlockMedia[0].Interface = "ATA";
sidecar.BlockMedia[0].LogicalBlocks = blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = physicalSectorSize;
sidecar.BlockMedia[0].LogicalBlockSize = blockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedias[0].MediaType = type;
sidecar.BlockMedias[0].MediaSubType = subType;
sidecar.BlockMedias[0].Interface = "ATA";
sidecar.BlockMedias[0].LogicalBlocks = blocks;
sidecar.BlockMedias[0].PhysicalBlockSize = physicalSectorSize;
sidecar.BlockMedias[0].LogicalBlockSize = blockSize;
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedias[0].Model = _dev.Model;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedias[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
sidecar.BlockMedias[0].Size = blocks * blockSize;
if(cylinders > 0 &&
heads > 0 &&
sectors > 0)
{
sidecar.BlockMedia[0].Cylinders = cylinders;
sidecar.BlockMedia[0].CylindersSpecified = true;
sidecar.BlockMedia[0].Heads = heads;
sidecar.BlockMedia[0].HeadsSpecified = true;
sidecar.BlockMedia[0].SectorsPerTrack = sectors;
sidecar.BlockMedia[0].SectorsPerTrackSpecified = true;
sidecar.BlockMedias[0].Cylinders = cylinders;
sidecar.BlockMedias[0].Heads = heads;
sidecar.BlockMedias[0].SectorsPerTrack = sectors;
}
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
var xmlFs = new FileStream(_outputPrefix + ".cicm.xml", FileMode.Create);
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
jsonFs.Close();
}
}

View File

@@ -37,13 +37,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Core.Logging;
using Aaru.Decoders.CD;
using Aaru.Devices;
using Schemas;
using Track = Aaru.CommonTypes.Structs.Track;
namespace Aaru.Core.Devices.Dumping;
@@ -146,7 +146,7 @@ partial class Dump
/// <param name="mcn">Disc media catalogue number</param>
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents,
void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardware currentTry, ExtentsULong extents,
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed,
MhddLog mhddLog, ref double minSpeed, uint subSize, MmcSubchannel supportedSubchannel,
ref double totalDuration, Track[] tracks, SubchannelLog subLog, MmcSubchannel desiredSubchannel,
@@ -242,7 +242,7 @@ partial class Dump
if(!sense &&
!_dev.Error)
{
mhddLog.Write(i + r, cmdDuration, 1);
mhddLog.Write(i + r, cmdDuration);
ibgLog.Write(i + r, currentSpeed * 1024);
extents.Add(i + r, 1, true);
DateTime writeStart = DateTime.Now;
@@ -324,7 +324,7 @@ partial class Dump
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead,
subSize, ref cmdBuf, blockSize, false);
mhddLog.Write(i, cmdDuration, 1);
mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, blocksToRead, true);
DateTime writeStart = DateTime.Now;

View File

@@ -38,16 +38,16 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Console;
using Aaru.Core.Logging;
using Aaru.Decoders.CD;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Schemas;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
namespace Aaru.Core.Devices.Dumping;
@@ -89,7 +89,7 @@ partial class Dump
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
void ReadCdData(ExtentsULong audioExtents, ulong blocks, uint blockSize, ref double currentSpeed,
DumpHardwareType currentTry, ExtentsULong extents, IbgLog ibgLog, ref double imageWriteDuration,
DumpHardware currentTry, ExtentsULong extents, IbgLog ibgLog, ref double imageWriteDuration,
long lastSector, ExtentsULong leadOutExtents, ref double maxSpeed, MhddLog mhddLog,
ref double minSpeed, out bool newTrim, bool nextData, int offsetBytes, bool read6, bool read10,
bool read12, bool read16, bool readcd, int sectorsForOffset, uint subSize,
@@ -476,7 +476,7 @@ partial class Dump
if(!sense &&
!_dev.Error)
{
mhddLog.Write(i + r, cmdDuration, 1);
mhddLog.Write(i + r, cmdDuration);
ibgLog.Write(i + r, currentSpeed * 1024);
extents.Add(i + r, 1, true);
DateTime writeStart = DateTime.Now;
@@ -596,7 +596,7 @@ partial class Dump
AaruConsole.DebugWriteLine("Dump-Media", Localization.Core.READ_error_0,
Sense.PrettifySense(senseBuf));
mhddLog.Write(i + r, cmdDuration < 500 ? 65535 : cmdDuration, 1);
mhddLog.Write(i + r, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i + r, 0);
_dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, 1, i + r);

View File

@@ -39,10 +39,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Console;
using Aaru.Core.Graphics;
using Aaru.Core.Logging;
@@ -50,7 +50,7 @@ using Aaru.Core.Media.Detection;
using Aaru.Database.Models;
using Aaru.Decoders.CD;
using Aaru.Devices;
using Schemas;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -69,7 +69,7 @@ sealed partial class Dump
uint blockSize; // Size of the read sector in bytes
CdOffset cdOffset; // Read offset from database
byte[] cmdBuf; // Data buffer
DumpHardwareType currentTry = null; // Current dump hardware try
DumpHardware currentTry = null; // Current dump hardware try
double currentSpeed = 0; // Current read speed
int? discOffset = null; // Disc write offset
DateTime dumpStart = DateTime.UtcNow; // Time of dump start
@@ -1380,14 +1380,14 @@ sealed partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputOptical.SetMetadata(metadata))
if(!outputOptical.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputOptical.ErrorMessage);
outputOptical.SetDumpHardware(_resume.Tries);
if(_preSidecar != null)
outputOptical.SetCicmMetadata(_preSidecar);
outputOptical.SetMetadata(_preSidecar);
foreach(KeyValuePair<byte, string> isrc in isrcs)
{

View File

@@ -37,16 +37,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.Console;
using Aaru.Core.Logging;
using Aaru.Decoders.CD;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Schemas;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
namespace Aaru.Core.Devices.Dumping;
@@ -72,7 +72,7 @@ partial class Dump
/// <param name="mcn">Disc media catalogue number</param>
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
void RetryCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, ExtentsULong extents,
void RetryCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardware currentTry, ExtentsULong extents,
int offsetBytes, bool readcd, int sectorsForOffset, uint subSize,
MmcSubchannel supportedSubchannel, ref double totalDuration, SubchannelLog subLog,
MmcSubchannel desiredSubchannel, Track[] tracks, Dictionary<byte, string> isrcs,

View File

@@ -38,13 +38,13 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Core.Logging;
using Aaru.Devices;
using Schemas;
using Track = Aaru.CommonTypes.Structs.Track;
namespace Aaru.Core.Devices.Dumping;
@@ -79,7 +79,7 @@ partial class Dump
// TODO: Use it
[SuppressMessage("ReSharper", "UnusedMember.Local")]
void DumpCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents,
void DumpCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardware currentTry, ExtentsULong extents,
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed,
MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, bool read12, bool read16,
bool readcd, MmcSubchannel supportedSubchannel, uint subSize, ref double totalDuration,
@@ -145,7 +145,7 @@ partial class Dump
if(!sense &&
!_dev.Error)
{
mhddLog.Write(i, cmdDuration, 1);
mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, _maximumReadable, true);
leadOutExtents.Remove(i);
@@ -252,7 +252,7 @@ partial class Dump
// TODO: Use it
[SuppressMessage("ReSharper", "UnusedMember.Local")]
void RetryCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents,
void RetryCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardware currentTry, ExtentsULong extents,
IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed,
MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, bool read12, bool read16,
bool readcd, MmcSubchannel supportedSubchannel, uint subSize, ref double totalDuration,
@@ -380,7 +380,7 @@ partial class Dump
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, 1);
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0);
}

View File

@@ -37,14 +37,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Core.Logging;
using Aaru.Decoders.CD;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Schemas;
using Track = Aaru.CommonTypes.Structs.Track;
namespace Aaru.Core.Devices.Dumping;
@@ -74,7 +74,7 @@ partial class Dump
/// <param name="mcn">Disc media catalogue number</param>
/// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
/// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
void TrimCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, ExtentsULong extents,
void TrimCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardware currentTry, ExtentsULong extents,
bool newTrim, int offsetBytes, bool read6, bool read10, bool read12, bool read16, bool readcd,
int sectorsForOffset, uint subSize, MmcSubchannel supportedSubchannel, bool supportsLongSectors,
ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel, Track[] tracks,

View File

@@ -39,13 +39,14 @@ using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Metadata;
using Aaru.Core.Logging;
using Aaru.Database;
using Aaru.Devices;
using Schemas;
using File = System.IO.File;
namespace Aaru.Core.Devices.Dumping;
@@ -88,7 +89,7 @@ public partial class Dump
readonly IBaseWritableImage _outputPlugin;
readonly string _outputPrefix;
readonly bool _persistent;
readonly CICMMetadataType _preSidecar;
readonly Metadata _preSidecar;
readonly bool _private;
readonly ushort _retryPasses;
readonly bool _retrySubchannel;
@@ -157,12 +158,11 @@ public partial class Dump
public Dump(bool doResume, Device dev, string devicePath, IBaseWritableImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw, bool persistent, bool stopOnError, Resume resume, DumpLog dumpLog,
Encoding encoding, string outputPrefix, string outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar, uint skip, bool metadata, bool trim, bool dumpFirstTrackPregap,
bool fixOffset, bool debug, DumpSubchannel subchannel, int speed, bool @private,
bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel, bool fixSubchannelCrc,
bool skipCdireadyHole, ErrorLog errorLog, bool generateSubchannels, uint maximumReadable,
bool useBufferedReads, bool storeEncrypted, bool titleKeys, uint ignoreCdrRunOuts, bool createGraph,
uint dimensions)
Metadata preSidecar, uint skip, bool metadata, bool trim, bool dumpFirstTrackPregap, bool fixOffset,
bool debug, DumpSubchannel subchannel, int speed, bool @private, bool fixSubchannelPosition,
bool retrySubchannel, bool fixSubchannel, bool fixSubchannelCrc, bool skipCdireadyHole,
ErrorLog errorLog, bool generateSubchannels, uint maximumReadable, bool useBufferedReads,
bool storeEncrypted, bool titleKeys, uint ignoreCdrRunOuts, bool createGraph, uint dimensions)
{
_doResume = doResume;
_dev = dev;

View File

@@ -423,7 +423,7 @@ public partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputBai.SetMetadata(metadata))
if(!outputBai.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputBai.ErrorMessage);
@@ -431,7 +431,7 @@ public partial class Dump
//outputBAI.SetDumpHardware();
if(_preSidecar != null)
outputBai.SetCicmMetadata(_preSidecar);
outputBai.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);

View File

@@ -34,6 +34,7 @@
using System;
using System.Collections.Generic;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.Decoders.Bluray;
@@ -43,7 +44,6 @@ using Aaru.Decoders.SCSI.MMC;
using Aaru.Decryption;
using Aaru.Decryption.DVD;
using Aaru.Devices;
using Schemas;
using DDS = Aaru.Decoders.DVD.DDS;
using DMI = Aaru.Decoders.Xbox.DMI;
using DVDDecryption = Aaru.Decryption.DVD.Dump;
@@ -802,36 +802,35 @@ partial class Dump
}
// TODO: Move somewhere else
internal static void AddMediaTagToSidecar(string outputPath, MediaTagType tagType, byte[] tag,
ref CICMMetadataType sidecar)
internal static void AddMediaTagToSidecar(string outputPath, MediaTagType tagType, byte[] tag, ref Metadata sidecar)
{
switch(tagType)
{
case MediaTagType.DVD_PFI:
sidecar.OpticalDisc[0].PFI = new DumpType
sidecar.OpticalDiscs[0].Pfi = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DVD_DMI:
sidecar.OpticalDisc[0].DMI = new DumpType
sidecar.OpticalDiscs[0].Dmi = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DVD_CMI:
case MediaTagType.HDDVD_CPI:
sidecar.OpticalDisc[0].CMI = new DumpType
sidecar.OpticalDiscs[0].Cmi = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
byte[] tmp = new byte[tag.Length + 4];
@@ -843,190 +842,190 @@ partial class Dump
if(cpy.HasValue &&
cpy.Value.CopyrightType != CopyrightType.NoProtection)
sidecar.OpticalDisc[0].CopyProtection = cpy.Value.CopyrightType.ToString();
sidecar.OpticalDiscs[0].CopyProtection = cpy.Value.CopyrightType.ToString();
break;
case MediaTagType.DVD_BCA:
case MediaTagType.BD_BCA:
sidecar.OpticalDisc[0].BCA = new DumpType
sidecar.OpticalDiscs[0].Bca = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.BD_DDS:
case MediaTagType.DVDRAM_DDS:
sidecar.OpticalDisc[0].DDS = new DumpType
sidecar.OpticalDiscs[0].Dds = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DVDRAM_SpareArea:
case MediaTagType.BD_SpareArea:
sidecar.OpticalDisc[0].SAI = new DumpType
sidecar.OpticalDiscs[0].Sai = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DVDR_PreRecordedInfo:
sidecar.OpticalDisc[0].PRI = new DumpType
sidecar.OpticalDiscs[0].Pri = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DVD_MediaIdentifier:
sidecar.OpticalDisc[0].MediaID = new DumpType
sidecar.OpticalDiscs[0].MediaID = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DVDR_PFI:
sidecar.OpticalDisc[0].PFIR = new DumpType
sidecar.OpticalDiscs[0].Pfir = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DVD_ADIP:
sidecar.OpticalDisc[0].ADIP = new DumpType
sidecar.OpticalDiscs[0].Adip = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.DCB:
sidecar.OpticalDisc[0].DCB = new DumpType
sidecar.OpticalDiscs[0].Dcb = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.BD_DI:
sidecar.OpticalDisc[0].DI = new DumpType
sidecar.OpticalDiscs[0].Di = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.Xbox_SecuritySector:
sidecar.OpticalDisc[0].Xbox ??= new XboxType();
sidecar.OpticalDiscs[0].Xbox ??= new Xbox();
sidecar.OpticalDisc[0].Xbox.SecuritySectors = new[]
sidecar.OpticalDiscs[0].Xbox.SecuritySectors = new List<XboxSecuritySector>
{
new XboxSecuritySectorsType
new()
{
RequestNumber = 0,
RequestVersion = 1,
SecuritySectors = new DumpType
SecuritySectors = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
}
}
};
break;
case MediaTagType.Xbox_PFI:
sidecar.OpticalDisc[0].Xbox ??= new XboxType();
sidecar.OpticalDiscs[0].Xbox ??= new Xbox();
sidecar.OpticalDisc[0].Xbox.PFI = new DumpType
sidecar.OpticalDiscs[0].Xbox.Pfi = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.Xbox_DMI:
sidecar.OpticalDisc[0].Xbox ??= new XboxType();
sidecar.OpticalDiscs[0].Xbox ??= new Xbox();
sidecar.OpticalDisc[0].Xbox.DMI = new DumpType
sidecar.OpticalDiscs[0].Xbox.Dmi = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.CD_FullTOC:
sidecar.OpticalDisc[0].TOC = new DumpType
sidecar.OpticalDiscs[0].Toc = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.CD_ATIP:
sidecar.OpticalDisc[0].ATIP = new DumpType
sidecar.OpticalDiscs[0].Atip = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.CD_PMA:
sidecar.OpticalDisc[0].PMA = new DumpType
sidecar.OpticalDiscs[0].Pma = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.CD_TEXT:
sidecar.OpticalDisc[0].LeadInCdText = new DumpType
sidecar.OpticalDiscs[0].LeadInCdText = new CommonTypes.AaruMetadata.Dump
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
};
break;
case MediaTagType.CD_FirstTrackPregap:
sidecar.OpticalDisc[0].FirstTrackPregrap = new[]
sidecar.OpticalDiscs[0].FirstTrackPregrap = new List<Border>
{
new BorderType
new()
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
}
};
break;
case MediaTagType.CD_LeadIn:
sidecar.OpticalDisc[0].LeadIn = new[]
sidecar.OpticalDiscs[0].LeadIn = new List<Border>
{
new BorderType
new()
{
Image = outputPath,
Size = (ulong)tag.Length,
Checksums = Checksum.GetChecksums(tag).ToArray()
Checksums = Checksum.GetChecksums(tag)
}
};

View File

@@ -34,12 +34,13 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Metadata;
using Schemas;
using MediaType = Aaru.CommonTypes.MediaType;
namespace Aaru.Core.Devices.Dumping;
@@ -55,7 +56,7 @@ partial class Dump
/// <param name="sessions">Disc sessions</param>
/// <param name="totalChkDuration">Total time spent doing checksums</param>
/// <param name="discOffset">Disc write offset</param>
void WriteOpticalSidecar(uint blockSize, ulong blocks, MediaType mediaType, LayersType layers,
void WriteOpticalSidecar(uint blockSize, ulong blocks, MediaType mediaType, Layers layers,
Dictionary<MediaTagType, byte[]> mediaTags, int sessions, out double totalChkDuration,
int? discOffset)
{
@@ -91,8 +92,8 @@ partial class Dump
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus;
CICMMetadataType sidecar = _sidecarClass.Create();
DateTime end = DateTime.UtcNow;
Metadata sidecar = _sidecarClass.Create();
DateTime end = DateTime.UtcNow;
if(_aborted)
return;
@@ -105,14 +106,14 @@ partial class Dump
if(_preSidecar != null)
{
_preSidecar.OpticalDisc = sidecar.OpticalDisc;
sidecar = _preSidecar;
_preSidecar.OpticalDiscs = sidecar.OpticalDiscs;
sidecar = _preSidecar;
}
List<(ulong start, string type)> filesystems = new();
if(sidecar.OpticalDisc[0].Track != null)
filesystems.AddRange(from xmlTrack in sidecar.OpticalDisc[0].Track
if(sidecar.OpticalDiscs[0].Track != null)
filesystems.AddRange(from xmlTrack in sidecar.OpticalDiscs[0].Track
where xmlTrack.FileSystemInformation != null
from partition in xmlTrack.FileSystemInformation where partition.FileSystems != null
from fileSystem in partition.FileSystems
@@ -126,19 +127,16 @@ partial class Dump
}).Distinct())
_dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, filesystem.start);
sidecar.OpticalDisc[0].Dimensions = Dimensions.DimensionsFromMediaType(mediaType);
sidecar.OpticalDiscs[0].Dimensions = Dimensions.DimensionsFromMediaType(mediaType);
(string type, string subType) discType = CommonTypes.Metadata.MediaType.MediaTypeToString(mediaType);
sidecar.OpticalDisc[0].DiscType = discType.type;
sidecar.OpticalDisc[0].DiscSubType = discType.subType;
sidecar.OpticalDisc[0].DumpHardwareArray = _resume.Tries.ToArray();
sidecar.OpticalDisc[0].Sessions = (uint)sessions;
sidecar.OpticalDisc[0].Layers = layers;
sidecar.OpticalDiscs[0].DiscType = discType.type;
sidecar.OpticalDiscs[0].DiscSubType = discType.subType;
sidecar.OpticalDiscs[0].DumpHardware = _resume.Tries;
sidecar.OpticalDiscs[0].Sessions = (uint)sessions;
sidecar.OpticalDiscs[0].Layers = layers;
if(discOffset.HasValue)
{
sidecar.OpticalDisc[0].Offset = (int)(discOffset / 4);
sidecar.OpticalDisc[0].OffsetSpecified = true;
}
sidecar.OpticalDiscs[0].Offset = (int)(discOffset / 4);
if(mediaTags != null)
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags.Where(tag => _outputPlugin.SupportedMediaTags.
@@ -147,10 +145,14 @@ partial class Dump
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
var xmlFs = new FileStream(_outputPrefix + ".cicm.xml", FileMode.Create);
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
jsonFs.Close();
}
}

View File

@@ -36,8 +36,10 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
@@ -47,7 +49,6 @@ using Aaru.Core.Graphics;
using Aaru.Core.Logging;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Schemas;
using MediaType = Aaru.CommonTypes.MediaType;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -263,8 +264,10 @@ partial class Dump
UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead));
_dumpLog.WriteLine(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, _dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private,
_dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
ret = outputFormat.Create(_outputPath, dskType, _formatOptions, blocks, blockSize);
// Cannot create image
@@ -342,8 +345,8 @@ partial class Dump
}
}
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
@@ -740,12 +743,12 @@ partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputFormat.SetMetadata(metadata))
if(!outputFormat.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputFormat.ErrorMessage);
if(_preSidecar != null)
outputFormat.SetCicmMetadata(_preSidecar);
outputFormat.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
@@ -793,7 +796,7 @@ partial class Dump
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus;
CICMMetadataType sidecar = _sidecarClass.Create();
Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow;
if(!_aborted)
@@ -814,14 +817,14 @@ partial class Dump
if(_preSidecar != null)
{
_preSidecar.BlockMedia = sidecar.BlockMedia;
sidecar = _preSidecar;
_preSidecar.BlockMedias = sidecar.BlockMedias;
sidecar = _preSidecar;
}
List<(ulong start, string type)> filesystems = new();
if(sidecar.BlockMedia[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
if(sidecar.BlockMedias[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedias[0].FileSystemInformation
where partition.FileSystems != null from fileSystem in partition.FileSystems
select (partition.StartSector, fileSystem.Type));
@@ -839,43 +842,47 @@ partial class Dump
filesystem.start);
}
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
(string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
sidecar.BlockMedia[0].DiskType = xmlType.type;
sidecar.BlockMedia[0].DiskSubType = xmlType.subType;
sidecar.BlockMedias[0].MediaType = xmlType.type;
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(_dev.Type == DeviceType.ATAPI)
sidecar.BlockMedia[0].Interface = "ATAPI";
sidecar.BlockMedias[0].Interface = "ATAPI";
else if(_dev.IsUsb)
sidecar.BlockMedia[0].Interface = "USB";
sidecar.BlockMedias[0].Interface = "USB";
else if(_dev.IsFireWire)
sidecar.BlockMedia[0].Interface = "FireWire";
sidecar.BlockMedias[0].Interface = "FireWire";
else
sidecar.BlockMedia[0].Interface = "SCSI";
sidecar.BlockMedias[0].Interface = "SCSI";
sidecar.BlockMedia[0].LogicalBlocks = blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize;
sidecar.BlockMedia[0].LogicalBlockSize = blockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedias[0].LogicalBlocks = blocks;
sidecar.BlockMedias[0].PhysicalBlockSize = physicalBlockSize;
sidecar.BlockMedias[0].LogicalBlockSize = blockSize;
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedias[0].Model = _dev.Model;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedias[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
sidecar.BlockMedias[0].Size = blocks * blockSize;
if(_dev.IsRemovable)
sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray();
sidecar.BlockMedias[0].DumpHardware = _resume.Tries;
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
var xmlFs = new FileStream(_outputPrefix + ".cicm.xml", FileMode.Create);
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
jsonFs.Close();
}
}

View File

@@ -36,8 +36,10 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
@@ -47,7 +49,6 @@ using Aaru.Core.Graphics;
using Aaru.Core.Logging;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Schemas;
using MediaType = Aaru.CommonTypes.MediaType;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -158,8 +159,10 @@ public partial class Dump
bool ret;
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, _dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private,
_dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
ret = outputFormat.Create(_outputPath, dskType, _formatOptions, blocks, blockSize);
// Cannot create image
@@ -177,8 +180,8 @@ public partial class Dump
start = DateTime.UtcNow;
double imageWriteDuration = 0;
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
@@ -591,14 +594,14 @@ public partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputFormat.SetMetadata(metadata))
if(!outputFormat.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputFormat.ErrorMessage);
outputFormat.SetDumpHardware(_resume.Tries);
if(_preSidecar != null)
outputFormat.SetCicmMetadata(_preSidecar);
outputFormat.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
@@ -646,7 +649,7 @@ public partial class Dump
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus;
CICMMetadataType sidecar = _sidecarClass.Create();
Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow;
if(!_aborted)
@@ -667,14 +670,14 @@ public partial class Dump
if(_preSidecar != null)
{
_preSidecar.BlockMedia = sidecar.BlockMedia;
sidecar = _preSidecar;
_preSidecar.BlockMedias = sidecar.BlockMedias;
sidecar = _preSidecar;
}
List<(ulong start, string type)> filesystems = new();
if(sidecar.BlockMedia[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
if(sidecar.BlockMedias[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedias[0].FileSystemInformation
where partition.FileSystems != null from fileSystem in partition.FileSystems
select (partition.StartSector, fileSystem.Type));
@@ -692,32 +695,36 @@ public partial class Dump
filesystem.start);
}
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
(string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
sidecar.BlockMedia[0].DiskType = xmlType.type;
sidecar.BlockMedia[0].DiskSubType = xmlType.subType;
sidecar.BlockMedia[0].Interface = "USB";
sidecar.BlockMedia[0].LogicalBlocks = blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = (int)blockSize;
sidecar.BlockMedia[0].LogicalBlockSize = (int)blockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedias[0].MediaType = xmlType.type;
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
sidecar.BlockMedias[0].Interface = "USB";
sidecar.BlockMedias[0].LogicalBlocks = blocks;
sidecar.BlockMedias[0].PhysicalBlockSize = (int)blockSize;
sidecar.BlockMedias[0].LogicalBlockSize = (int)blockSize;
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedias[0].Model = _dev.Model;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedias[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
sidecar.BlockMedias[0].Size = blocks * blockSize;
if(_dev.IsRemovable)
sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray();
sidecar.BlockMedias[0].DumpHardware = _resume.Tries;
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
var xmlFs = new FileStream(_outputPrefix + ".cicm.xml", FileMode.Create);
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
jsonFs.Close();
}
}

View File

@@ -36,16 +36,16 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Console;
using Aaru.Core.Graphics;
using Aaru.Core.Logging;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Schemas;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -158,8 +158,10 @@ public partial class Dump
bool ret;
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, _dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private,
_dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010);
ret = outputOptical.Create(_outputPath, dskType, _formatOptions, blocks, blockSize);
// Cannot create image
@@ -191,8 +193,8 @@ public partial class Dump
}
});
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
@@ -589,14 +591,14 @@ public partial class Dump
MediaPartNumber = mediaPartNumber
};
if(!outputOptical.SetMetadata(metadata))
if(!outputOptical.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputOptical.ErrorMessage);
outputOptical.SetDumpHardware(_resume.Tries);
if(_preSidecar != null)
outputOptical.SetCicmMetadata(_preSidecar);
outputOptical.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);

View File

@@ -32,9 +32,9 @@
using System;
using System.Collections.Generic;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Metadata;
using Schemas;
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -64,7 +64,7 @@ static class ResumeSupport
/// progress dump
/// </exception>
internal static void Process(bool isLba, bool removable, ulong blocks, string manufacturer, string model,
string serial, PlatformID platform, ref Resume resume, ref DumpHardwareType currentTry,
string serial, PlatformID platform, ref Resume resume, ref DumpHardware currentTry,
ref ExtentsULong extents, string firmware, bool @private, bool force,
bool isTape = false)
{
@@ -102,7 +102,7 @@ static class ResumeSupport
InvalidOperationException(string.Format(Localization.Core.Resume_file_different_number_of_blocks_not_continuing,
resume.LastBlock + 1, blocks));
foreach(DumpHardwareType oldTry in resume.Tries)
foreach(DumpHardware oldTry in resume.Tries)
{
if(!removable &&
!force)
@@ -153,9 +153,9 @@ static class ResumeSupport
if(currentTry != null)
return;
currentTry = new DumpHardwareType
currentTry = new DumpHardware
{
Software = CommonTypes.Metadata.Version.GetSoftwareType(),
Software = CommonTypes.Metadata.Version.GetSoftware(),
Manufacturer = manufacturer,
Model = model,
Serial = serial,
@@ -169,16 +169,16 @@ static class ResumeSupport
{
resume = new Resume
{
Tries = new List<DumpHardwareType>(),
Tries = new List<DumpHardware>(),
CreationDate = DateTime.UtcNow,
BadBlocks = new List<ulong>(),
LastBlock = isTape ? 0 : blocks - 1,
Tape = isTape
};
currentTry = new DumpHardwareType
currentTry = new DumpHardware
{
Software = CommonTypes.Metadata.Version.GetSoftwareType(),
Software = CommonTypes.Metadata.Version.GetSoftware(),
Manufacturer = manufacturer,
Model = model,
Serial = serial,

View File

@@ -36,21 +36,23 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Xml.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Metadata;
using Aaru.CommonTypes.Structs;
using Aaru.Core.Logging;
using Aaru.Decoders.SCSI;
using Aaru.Decoders.SCSI.SSC;
using Aaru.Devices;
using Aaru.Helpers;
using Schemas;
using MediaType = Aaru.CommonTypes.MediaType;
using TapeFile = Aaru.CommonTypes.Structs.TapeFile;
using TapePartition = Aaru.CommonTypes.Structs.TapePartition;
using Version = Aaru.CommonTypes.Interop.Version;
namespace Aaru.Core.Devices.Dumping;
@@ -498,8 +500,8 @@ partial class Dump
}
}
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
@@ -1306,12 +1308,12 @@ partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputTape.SetMetadata(metadata))
if(!outputTape.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputTape.ErrorMessage);
if(_preSidecar != null)
outputTape.SetCicmMetadata(_preSidecar);
outputTape.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
@@ -1367,7 +1369,7 @@ partial class Dump
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus;
CICMMetadataType sidecar = _sidecarClass.Create();
Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow;
if(!_aborted)
@@ -1388,14 +1390,14 @@ partial class Dump
if(_preSidecar != null)
{
_preSidecar.BlockMedia = sidecar.BlockMedia;
sidecar = _preSidecar;
_preSidecar.BlockMedias = sidecar.BlockMedias;
sidecar = _preSidecar;
}
List<(ulong start, string type)> filesystems = new();
if(sidecar.BlockMedia[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
if(sidecar.BlockMedias[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedias[0].FileSystemInformation
where partition.FileSystems != null from fileSystem in partition.FileSystems
select (partition.StartSector, fileSystem.Type));
@@ -1413,44 +1415,48 @@ partial class Dump
filesystem.start);
}
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
(string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
sidecar.BlockMedia[0].DiskType = xmlType.type;
sidecar.BlockMedia[0].DiskSubType = xmlType.subType;
sidecar.BlockMedias[0].MediaType = xmlType.type;
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
// TODO: Implement device firmware revision
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(_dev.Type == DeviceType.ATAPI)
sidecar.BlockMedia[0].Interface = "ATAPI";
sidecar.BlockMedias[0].Interface = "ATAPI";
else if(_dev.IsUsb)
sidecar.BlockMedia[0].Interface = "USB";
sidecar.BlockMedias[0].Interface = "USB";
else if(_dev.IsFireWire)
sidecar.BlockMedia[0].Interface = "FireWire";
sidecar.BlockMedias[0].Interface = "FireWire";
else
sidecar.BlockMedia[0].Interface = "SCSI";
sidecar.BlockMedias[0].Interface = "SCSI";
sidecar.BlockMedia[0].LogicalBlocks = blocks;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedias[0].LogicalBlocks = blocks;
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedias[0].Model = _dev.Model;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedias[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
sidecar.BlockMedias[0].Size = blocks * blockSize;
if(_dev.IsRemovable)
sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray();
sidecar.BlockMedias[0].DumpHardware = _resume.Tries;
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
var xmlFs = new FileStream(_outputPrefix + ".cicm.xml", FileMode.Create);
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
jsonFs.Close();
}
}

View File

@@ -27,6 +27,7 @@
using System;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
@@ -34,7 +35,6 @@ using Aaru.Core.Logging;
using Aaru.Decoders.DVD;
using Aaru.Decryption;
using Aaru.Decryption.DVD;
using Schemas;
using DVDDecryption = Aaru.Decryption.DVD.Dump;
// ReSharper disable JoinDeclarationAndInitializer
@@ -62,7 +62,7 @@ partial class Dump
/// <param name="newTrim">Set if we need to start a trim</param>
/// <param name="dvdDecrypt">DVD CSS decryption module</param>
/// <param name="discKey">The DVD disc key</param>
void ReadSbcData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize, DumpHardwareType currentTry,
void ReadSbcData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize, DumpHardware currentTry,
ExtentsULong extents, ref double currentSpeed, ref double minSpeed, ref double maxSpeed,
ref double totalDuration, Reader scsiReader, MhddLog mhddLog, IbgLog ibgLog,
ref double imageWriteDuration, ref bool newTrim, ref DVDDecryption dvdDecrypt, byte[] discKey)

View File

@@ -35,13 +35,14 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Metadata;
using Aaru.CommonTypes.Structs;
using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.Console;
using Aaru.Core.Graphics;
@@ -52,11 +53,12 @@ using Aaru.Decoders.DVD;
using Aaru.Decoders.SCSI;
using Aaru.Decoders.SCSI.MMC;
using Aaru.Devices;
using Schemas;
using DeviceReport = Aaru.Core.Devices.Report.DeviceReport;
using DVDDecryption = Aaru.Decryption.DVD.Dump;
using MediaType = Aaru.CommonTypes.MediaType;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
using Usb = Aaru.CommonTypes.AaruMetadata.Usb;
using Version = Aaru.CommonTypes.Interop.Version;
// ReSharper disable JoinDeclarationAndInitializer
@@ -369,8 +371,10 @@ partial class Dump
UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead));
_dumpLog.WriteLine(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, _dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private,
_dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile);
bool imageCreated = false;
if(!opticalDisc)
@@ -697,8 +701,8 @@ partial class Dump
}
}
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
@@ -1023,12 +1027,12 @@ partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputFormat.SetMetadata(metadata))
if(!outputFormat.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputFormat.ErrorMessage);
if(_preSidecar != null)
outputFormat.SetCicmMetadata(_preSidecar);
outputFormat.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
@@ -1082,7 +1086,7 @@ partial class Dump
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus;
CICMMetadataType sidecar = _sidecarClass.Create();
Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow;
if(!_aborted)
@@ -1103,8 +1107,8 @@ partial class Dump
if(_preSidecar != null)
{
_preSidecar.BlockMedia = sidecar.BlockMedia;
sidecar = _preSidecar;
_preSidecar.BlockMedias = sidecar.BlockMedias;
sidecar = _preSidecar;
}
// All USB flash drives report as removable, even if the media is not removable
@@ -1114,15 +1118,15 @@ partial class Dump
if(_dev.IsUsb &&
_dev.UsbDescriptors != null)
if(outputFormat.SupportedMediaTags.Contains(MediaTagType.USB_Descriptors))
sidecar.BlockMedia[0].USB = new USBType
sidecar.BlockMedias[0].Usb = new Usb
{
ProductID = _dev.UsbProductId,
VendorID = _dev.UsbVendorId,
Descriptors = new DumpType
Descriptors = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)_dev.UsbDescriptors.Length,
Checksums = Checksum.GetChecksums(_dev.UsbDescriptors).ToArray()
Checksums = Checksum.GetChecksums(_dev.UsbDescriptors)
}
};
@@ -1134,13 +1138,13 @@ partial class Dump
if(!sense)
if(outputFormat.SupportedMediaTags.Contains(MediaTagType.ATAPI_IDENTIFY))
sidecar.BlockMedia[0].ATA = new ATAType
sidecar.BlockMedias[0].ATA = new ATA
{
Identify = new DumpType
Identify = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
Checksums = Checksum.GetChecksums(cmdBuf)
}
};
}
@@ -1150,13 +1154,13 @@ partial class Dump
if(!sense)
{
if(outputFormat.SupportedMediaTags.Contains(MediaTagType.SCSI_INQUIRY))
sidecar.BlockMedia[0].SCSI = new SCSIType
sidecar.BlockMedias[0].SCSI = new SCSI
{
Inquiry = new DumpType
Inquiry = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
Checksums = Checksum.GetChecksums(cmdBuf)
}
};
@@ -1171,25 +1175,25 @@ partial class Dump
if(pages != null)
{
List<EVPDType> evpds = new List<EVPDType>();
List<Evpd> evpds = new();
foreach(byte page in pages)
{
dumpLog.WriteLine("Requesting page {0:X2}h.", page);
sense = dev.ScsiInquiry(out cmdBuf, out _, page);
if(sense) continue;
EVPDType evpd = new EVPDType
Evpd evpd = new()
{
Image = $"{outputPrefix}.evpd_{page:X2}h.bin",
Checksums = Checksum.GetChecksums(cmdBuf).ToArray(),
Checksums = Checksum.GetChecksums(cmdBuf),
Size = cmdBuf.Length
};
evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray();
evpd.Checksums = Checksum.GetChecksums(cmdBuf);
DataFile.WriteTo("SCSI Dump", evpd.Image, cmdBuf);
evpds.Add(evpd);
}
if(evpds.Count > 0) sidecar.BlockMedia[0].SCSI.EVPD = evpds.ToArray();
if(evpds.Count > 0) sidecar.BlockMedias[0].SCSI.Evpds = evpds;
}
}
*/
@@ -1209,11 +1213,11 @@ partial class Dump
!_dev.Error)
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
if(outputFormat.SupportedMediaTags.Contains(MediaTagType.SCSI_MODESENSE_10))
sidecar.BlockMedia[0].SCSI.ModeSense10 = new DumpType
sidecar.BlockMedias[0].SCSI.ModeSense10 = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
Checksums = Checksum.GetChecksums(cmdBuf)
};
UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6);
@@ -1233,19 +1237,19 @@ partial class Dump
!_dev.Error)
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
if(outputFormat.SupportedMediaTags.Contains(MediaTagType.SCSI_MODESENSE_6))
sidecar.BlockMedia[0].SCSI.ModeSense = new DumpType
sidecar.BlockMedias[0].SCSI.ModeSense = new CommonTypes.AaruMetadata.Dump
{
Image = _outputPath,
Size = (ulong)cmdBuf.Length,
Checksums = Checksum.GetChecksums(cmdBuf).ToArray()
Checksums = Checksum.GetChecksums(cmdBuf)
};
}
}
List<(ulong start, string type)> filesystems = new();
if(sidecar.BlockMedia[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation
if(sidecar.BlockMedias[0].FileSystemInformation != null)
filesystems.AddRange(from partition in sidecar.BlockMedias[0].FileSystemInformation
where partition.FileSystems != null
from fileSystem in partition.FileSystems
select (partition.StartSector, fileSystem.Type));
@@ -1264,46 +1268,50 @@ partial class Dump
filesystem.start);
}
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType);
(string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
sidecar.BlockMedia[0].DiskType = xmlType.type;
sidecar.BlockMedia[0].DiskSubType = xmlType.subType;
sidecar.BlockMedias[0].MediaType = xmlType.type;
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
// TODO: Implement device firmware revision
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(_dev.Type == DeviceType.ATAPI)
sidecar.BlockMedia[0].Interface = "ATAPI";
sidecar.BlockMedias[0].Interface = "ATAPI";
else if(_dev.IsUsb)
sidecar.BlockMedia[0].Interface = "USB";
sidecar.BlockMedias[0].Interface = "USB";
else if(_dev.IsFireWire)
sidecar.BlockMedia[0].Interface = "FireWire";
sidecar.BlockMedias[0].Interface = "FireWire";
else
sidecar.BlockMedia[0].Interface = "SCSI";
sidecar.BlockMedias[0].Interface = "SCSI";
sidecar.BlockMedia[0].LogicalBlocks = blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize;
sidecar.BlockMedia[0].LogicalBlockSize = logicalBlockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedias[0].LogicalBlocks = blocks;
sidecar.BlockMedias[0].PhysicalBlockSize = physicalBlockSize;
sidecar.BlockMedias[0].LogicalBlockSize = logicalBlockSize;
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedias[0].Model = _dev.Model;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedias[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
sidecar.BlockMedias[0].Size = blocks * blockSize;
if(_dev.IsRemovable)
sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray();
sidecar.BlockMedias[0].DumpHardware = _resume.Tries;
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
var xmlFs = new FileStream(_outputPrefix + ".cicm.xml", FileMode.Create);
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
jsonFs.Close();
}
}
}

View File

@@ -26,6 +26,7 @@
// ****************************************************************************/
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
@@ -36,7 +37,6 @@ using Aaru.Decoders.SCSI;
using Aaru.Decryption;
using Aaru.Decryption.DVD;
using Aaru.Devices;
using Schemas;
using DVDDecryption = Aaru.Decryption.DVD.Dump;
// ReSharper disable JoinDeclarationAndInitializer
@@ -53,7 +53,7 @@ partial class Dump
/// <param name="totalDuration">Total time spent in commands</param>
/// <param name="scsiReader">SCSI reader</param>
/// <param name="blankExtents">Blank extents</param>
void RetrySbcData(Reader scsiReader, DumpHardwareType currentTry, ExtentsULong extents, ref double totalDuration,
void RetrySbcData(Reader scsiReader, DumpHardware currentTry, ExtentsULong extents, ref double totalDuration,
ExtentsULong blankExtents)
{
int pass = 1;
@@ -326,7 +326,7 @@ partial class Dump
}
if(newBlank)
_resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents);
_resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents).ToArray();
EndProgress?.Invoke();
}

View File

@@ -4,13 +4,13 @@
using System;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Core.Logging;
using Aaru.Decoders.SCSI;
using Aaru.Helpers;
using Schemas;
namespace Aaru.Core.Devices.Dumping;
@@ -35,7 +35,7 @@ partial class Dump
/// <param name="imageWriteDuration">Total time spent writing to image</param>
/// <param name="newTrim">Set if we need to start a trim</param>
/// <param name="blankExtents">Blank extents</param>
void ReadOpticalData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize, DumpHardwareType currentTry,
void ReadOpticalData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize, DumpHardware currentTry,
ExtentsULong extents, ref double currentSpeed, ref double minSpeed, ref double maxSpeed,
ref double totalDuration, Reader scsiReader, MhddLog mhddLog, IbgLog ibgLog,
ref double imageWriteDuration, ref bool newTrim, ref ExtentsULong blankExtents)
@@ -148,7 +148,7 @@ partial class Dump
}
if(_resume != null && canMediumScan)
_resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents);
_resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents).ToArray();
EndProgress?.Invoke();
}

View File

@@ -28,9 +28,9 @@
// ReSharper disable InlineOutVariableDeclaration
// ReSharper disable TooWideLocalVariableScope
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Schemas;
namespace Aaru.Core.Devices.Dumping;
@@ -41,7 +41,7 @@ partial class Dump
/// <param name="extents">Correctly dump extents</param>
/// <param name="currentTry">Resume information</param>
/// <param name="blankExtents">Blank extents</param>
void TrimSbcData(Reader scsiReader, ExtentsULong extents, DumpHardwareType currentTry, ExtentsULong blankExtents)
void TrimSbcData(Reader scsiReader, ExtentsULong extents, DumpHardware currentTry, ExtentsULong blankExtents)
{
ulong[] tmpArray = _resume.BadBlocks.ToArray();
bool sense;
@@ -95,6 +95,6 @@ partial class Dump
}
if(newBlank)
_resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents);
_resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents).ToArray();
}
}

View File

@@ -36,8 +36,10 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
@@ -46,7 +48,6 @@ using Aaru.Core.Graphics;
using Aaru.Core.Logging;
using Aaru.Decoders.MMC;
using Aaru.Decoders.SecureDigital;
using Schemas;
using CSD = Aaru.Decoders.MMC.CSD;
using DeviceType = Aaru.CommonTypes.Enums.DeviceType;
using MediaType = Aaru.CommonTypes.MediaType;
@@ -418,8 +419,8 @@ public partial class Dump
if(_skip < blocksToRead)
_skip = blocksToRead;
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(true, false, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force);
@@ -457,8 +458,10 @@ public partial class Dump
}
}
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, _dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sdProfile);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private,
_dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", sdProfile);
ret = outputFormat.Create(_outputPath,
_dev.Type == DeviceType.SecureDigital ? MediaType.SecureDigital : MediaType.MMC,
@@ -867,12 +870,12 @@ public partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputFormat.SetMetadata(metadata))
if(!outputFormat.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputFormat.ErrorMessage);
if(_preSidecar != null)
outputFormat.SetCicmMetadata(_preSidecar);
outputFormat.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
@@ -916,14 +919,14 @@ public partial class Dump
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus;
CICMMetadataType sidecar = _sidecarClass.Create();
Metadata sidecar = _sidecarClass.Create();
if(!_aborted)
{
if(_preSidecar != null)
{
_preSidecar.BlockMedia = sidecar.BlockMedia;
sidecar = _preSidecar;
_preSidecar.BlockMedias = sidecar.BlockMedias;
sidecar = _preSidecar;
}
end = DateTime.UtcNow;
@@ -949,39 +952,43 @@ public partial class Dump
case DeviceType.MMC:
xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(MediaType.MMC);
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(MediaType.MMC);
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(MediaType.MMC);
break;
case DeviceType.SecureDigital:
CommonTypes.Metadata.MediaType.MediaTypeToString(MediaType.SecureDigital);
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(MediaType.SecureDigital);
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(MediaType.SecureDigital);
break;
}
sidecar.BlockMedia[0].DiskType = xmlType.type;
sidecar.BlockMedia[0].DiskSubType = xmlType.subType;
sidecar.BlockMedias[0].MediaType = xmlType.type;
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
// TODO: Implement device firmware revision
sidecar.BlockMedia[0].LogicalBlocks = blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = physicalBlockSize > 0 ? physicalBlockSize : blockSize;
sidecar.BlockMedia[0].LogicalBlockSize = blockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedias[0].LogicalBlocks = blocks;
sidecar.BlockMedias[0].PhysicalBlockSize = physicalBlockSize > 0 ? physicalBlockSize : blockSize;
sidecar.BlockMedias[0].LogicalBlockSize = blockSize;
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedias[0].Model = _dev.Model;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedias[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
sidecar.BlockMedias[0].Size = blocks * blockSize;
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
var xmlFs = new FileStream(_outputPrefix + ".cicm.xml", FileMode.Create);
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
WriteIndented = true
});
jsonFs.Close();
}
}

View File

@@ -36,11 +36,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Interop;
using Aaru.CommonTypes.Structs;
using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.Console;
using Aaru.Core.Graphics;
@@ -49,9 +49,10 @@ using Aaru.Decoders.DVD;
using Aaru.Decoders.SCSI;
using Aaru.Decoders.Xbox;
using Aaru.Devices;
using Schemas;
using Device = Aaru.Devices.Remote.Device;
using Layers = Aaru.CommonTypes.AaruMetadata.Layers;
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -498,8 +499,10 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead);
UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead));
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, _dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private,
_dimensions);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010);
ret = outputFormat.Create(_outputPath, dskType, _formatOptions, blocks, blockSize);
// Cannot create image
@@ -517,10 +520,10 @@ partial class Dump
start = DateTime.UtcNow;
double imageWriteDuration = 0;
double cmdDuration = 0;
uint saveBlocksToRead = blocksToRead;
DumpHardwareType currentTry = null;
ExtentsULong extents = null;
double cmdDuration = 0;
uint saveBlocksToRead = blocksToRead;
DumpHardware currentTry = null;
ExtentsULong extents = null;
ResumeSupport.Process(true, true, totalSize, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force);
@@ -1262,12 +1265,12 @@ partial class Dump
ApplicationVersion = Version.GetVersion()
};
if(!outputFormat.SetMetadata(metadata))
if(!outputFormat.SetImageInfo(metadata))
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
outputFormat.ErrorMessage);
if(_preSidecar != null)
outputFormat.SetCicmMetadata(_preSidecar);
outputFormat.SetMetadata(_preSidecar);
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
@@ -1292,16 +1295,16 @@ partial class Dump
if(_metadata)
{
var layers = new LayersType
var layers = new Layers
{
type = LayersTypeType.OTP,
typeSpecified = true,
Sectors = new SectorsType[1]
};
layers.Sectors[0] = new SectorsType
{
Value = layerBreak
Type = LayerType.OTP,
Sectors = new List<Sectors>
{
new()
{
Value = layerBreak
}
}
};
WriteOpticalSidecar(blockSize, blocks, dskType, layers, mediaTags, 1, out totalChkDuration, null);

View File

@@ -36,6 +36,7 @@ using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
@@ -49,12 +50,12 @@ using Aaru.Decoders.PCMCIA;
using Aaru.Decoders.SCSI;
using Aaru.Decoders.Xbox;
using Aaru.Helpers;
using Schemas;
using Spectre.Console;
using DDS = Aaru.Decoders.DVD.DDS;
using DMI = Aaru.Decoders.Xbox.DMI;
using Inquiry = Aaru.Decoders.SCSI.Inquiry;
using Session = Aaru.CommonTypes.Structs.Session;
using Track = Aaru.CommonTypes.Structs.Track;
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
namespace Aaru.Core;
@@ -105,7 +106,7 @@ public static class ImageInfo
AaruConsole.WriteLine(Localization.Core.Last_modified_on_0, imageFormat.Info.LastModificationTime);
AaruConsole.WriteLine(Localization.Core.Contains_a_media_of_type_0_and_XML_type_1_WithMarkup,
imageFormat.Info.MediaType, imageFormat.Info.XmlMediaType);
imageFormat.Info.MediaType, imageFormat.Info.MetadataMediaType);
AaruConsole.WriteLine(imageFormat.Info.HasPartitions ? Localization.Core.Has_partitions
: Localization.Core.Doesnt_have_partitions);
@@ -161,9 +162,9 @@ public static class ImageInfo
AaruConsole.WriteLine(Localization.Core.Drive_firmware_info_0_WithMarkup,
Markup.Escape(imageFormat.Info.DriveFirmwareRevision));
if(imageFormat.Info.Cylinders > 0 &&
imageFormat.Info is { Heads: > 0, SectorsPerTrack: > 0 } &&
imageFormat.Info.XmlMediaType != XmlMediaType.OpticalDisc &&
if(imageFormat.Info.Cylinders > 0 &&
imageFormat.Info is { Heads: > 0, SectorsPerTrack: > 0 } &&
imageFormat.Info.MetadataMediaType != MetadataMediaType.OpticalDisc &&
imageFormat is not ITapeImage { IsTape: true })
AaruConsole.WriteLine(Localization.Core.Media_geometry_0_cylinders_1_heads_2_sectors_per_track_WithMarkup,
imageFormat.Info.Cylinders, imageFormat.Info.Heads, imageFormat.Info.SectorsPerTrack);
@@ -192,7 +193,7 @@ public static class ImageInfo
AaruConsole.WriteLine();
if(imageFormat.Info.XmlMediaType == XmlMediaType.LinearMedia)
if(imageFormat.Info.MetadataMediaType == MetadataMediaType.LinearMedia)
PrintByteAddressableImageInfo(imageFormat as IByteAddressableImage);
else
PrintBlockImageInfo(imageFormat as IMediaImage);
@@ -208,7 +209,7 @@ public static class ImageInfo
int osLen = Localization.Core.Title_Operating_system.Length;
int sectorLen = Localization.Core.Title_Start.Length;
foreach(DumpHardwareType dump in imageFormat.DumpHardware)
foreach(DumpHardware dump in imageFormat.DumpHardware)
{
if(dump.Manufacturer?.Length > manufacturerLen)
manufacturerLen = dump.Manufacturer.Length;
@@ -228,7 +229,7 @@ public static class ImageInfo
if(dump.Software?.OperatingSystem?.Length > osLen)
osLen = dump.Software.OperatingSystem.Length;
foreach(ExtentType extent in dump.Extents)
foreach(Extent extent in dump.Extents)
{
if($"{extent.Start}".Length > sectorLen)
sectorLen = $"{extent.Start}".Length;
@@ -252,9 +253,9 @@ public static class ImageInfo
table.AddColumn(Localization.Core.Title_Start);
table.AddColumn(Localization.Core.Title_End);
foreach(DumpHardwareType dump in imageFormat.DumpHardware)
foreach(DumpHardware dump in imageFormat.DumpHardware)
{
foreach(ExtentType extent in dump.Extents)
foreach(Extent extent in dump.Extents)
table.AddRow(Markup.Escape(dump.Manufacturer ?? ""), Markup.Escape(dump.Model ?? ""),
Markup.Escape(dump.Serial ?? ""), Markup.Escape(dump.Software.Name ?? ""),
Markup.Escape(dump.Software.Version ?? ""),
@@ -527,7 +528,9 @@ public static class ImageInfo
if(errno == ErrorNumber.NoError)
{
AaruConsole.WriteLine(Localization.Core.DVD_RAM_Disc_Definition_Structure_contained_in_image_WithMarkup);
AaruConsole.WriteLine(Localization.Core.
DVD_RAM_Disc_Definition_Structure_contained_in_image_WithMarkup);
AaruConsole.Write("{0}", DDS.Prettify(dds));
AaruConsole.WriteLine();
}

View File

@@ -35,8 +35,8 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Interfaces;
using Schemas;
namespace Aaru.Core;
@@ -53,24 +53,24 @@ public sealed partial class Sidecar
/// <param name="sidecar">Metadata sidecar</param>
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
static void AudioMedia(IBaseImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar,
Encoding encoding)
{
sidecar.AudioMedia = new[]
sidecar.AudioMedia = new List<AudioMedia>
{
new AudioMediaType
new()
{
Checksums = imgChecksums.ToArray(),
Image = new ImageType
Checksums = imgChecksums,
Image = new Image
{
format = image.Format,
offset = 0,
offsetSpecified = true,
Value = Path.GetFileName(imagePath)
Format = image.Format,
Offset = 0,
Value = Path.GetFileName(imagePath)
},
Size = (ulong)fi.Length,
Sequence = new SequenceType
Sequence = new Sequence
{
MediaTitle = image.Info.MediaTitle
Title = image.Info.MediaTitle
}
}
};

View File

@@ -36,19 +36,23 @@ using System.IO;
using System.Linq;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Metadata;
using Aaru.CommonTypes.Structs;
using Aaru.CommonTypes.Structs.Devices.ATA;
using Aaru.Console;
using Aaru.Decoders.PCMCIA;
using Aaru.DiscImages;
using Aaru.Filters;
using Aaru.Helpers;
using Schemas;
using Directory = System.IO.Directory;
using File = System.IO.File;
using MediaType = Aaru.CommonTypes.Metadata.MediaType;
using Partition = Aaru.CommonTypes.Partition;
using Pcmcia = Aaru.CommonTypes.AaruMetadata.Pcmcia;
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
using Usb = Aaru.CommonTypes.AaruMetadata.Usb;
namespace Aaru.Core;
@@ -64,27 +68,26 @@ public sealed partial class Sidecar
/// <param name="sidecar">Metadata sidecar</param>
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
void BlockMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar, Encoding encoding)
{
if(_aborted)
return;
sidecar.BlockMedia = new[]
sidecar.BlockMedias = new List<BlockMedia>
{
new BlockMediaType
new()
{
Checksums = imgChecksums.ToArray(),
Image = new ImageType
Checksums = imgChecksums,
Image = new Image
{
format = image.Format,
offset = 0,
offsetSpecified = true,
Value = Path.GetFileName(imagePath)
Format = image.Format,
Offset = 0,
Value = Path.GetFileName(imagePath)
},
Size = (ulong)fi.Length,
Sequence = new SequenceType
Sequence = new Sequence
{
MediaTitle = image.Info.MediaTitle
Title = image.Info.MediaTitle
}
}
};
@@ -92,13 +95,13 @@ public sealed partial class Sidecar
if(image.Info.MediaSequence != 0 &&
image.Info.LastMediaSequence != 0)
{
sidecar.BlockMedia[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
sidecar.BlockMedia[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
sidecar.BlockMedias[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
sidecar.BlockMedias[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
}
else
{
sidecar.BlockMedia[0].Sequence.MediaSequence = 1;
sidecar.BlockMedia[0].Sequence.TotalMedia = 1;
sidecar.BlockMedias[0].Sequence.MediaSequence = 1;
sidecar.BlockMedias[0].Sequence.TotalMedia = 1;
}
UpdateStatus(Localization.Core.Hashing_media_tags);
@@ -118,11 +121,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].ATA = new ATAType
sidecar.BlockMedias[0].ATA = new ATA
{
Identify = new DumpType
Identify = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
}
};
@@ -134,11 +137,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].ATA = new ATAType
sidecar.BlockMedias[0].ATA = new ATA
{
Identify = new DumpType
Identify = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
}
};
@@ -150,11 +153,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].PCMCIA = new PCMCIAType
sidecar.BlockMedias[0].Pcmcia = new Pcmcia
{
CIS = new DumpType
Cis = new Dump
{
Checksums = Checksum.GetChecksums(cis).ToArray(),
Checksums = Checksum.GetChecksums(cis),
Size = (ulong)cis.Length
}
};
@@ -171,11 +174,9 @@ public sealed partial class Sidecar
if(manfid != null)
{
sidecar.BlockMedia[0].PCMCIA.ManufacturerCode = manfid.ManufacturerID;
sidecar.BlockMedias[0].Pcmcia.ManufacturerCode = manfid.ManufacturerID;
sidecar.BlockMedia[0].PCMCIA.CardCode = manfid.CardID;
sidecar.BlockMedia[0].PCMCIA.ManufacturerCodeSpecified = true;
sidecar.BlockMedia[0].PCMCIA.CardCodeSpecified = true;
sidecar.BlockMedias[0].Pcmcia.CardCode = manfid.CardID;
}
break;
@@ -184,13 +185,14 @@ public sealed partial class Sidecar
if(vers != null)
{
sidecar.BlockMedia[0].PCMCIA.Manufacturer = vers.Manufacturer;
sidecar.BlockMedia[0].PCMCIA.ProductName = vers.Product;
sidecar.BlockMedias[0].Pcmcia.Manufacturer = vers.Manufacturer;
sidecar.BlockMedias[0].Pcmcia.ProductName = vers.Product;
sidecar.BlockMedia[0].PCMCIA.Compliance =
sidecar.BlockMedias[0].Pcmcia.Compliance =
$"{vers.MajorVersion}.{vers.MinorVersion}";
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = vers.AdditionalInformation;
sidecar.BlockMedias[0].Pcmcia.AdditionalInformation =
new List<string>(vers.AdditionalInformation);
}
break;
@@ -203,11 +205,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].SCSI = new SCSIType
sidecar.BlockMedias[0].SCSI = new SCSI
{
Inquiry = new DumpType
Inquiry = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
}
};
@@ -219,11 +221,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType();
sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital();
sidecar.BlockMedia[0].SecureDigital.CID = new DumpType
sidecar.BlockMedias[0].SecureDigital.CID = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -234,11 +236,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType();
sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital();
sidecar.BlockMedia[0].SecureDigital.CSD = new DumpType
sidecar.BlockMedias[0].SecureDigital.CSD = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -249,11 +251,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType();
sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital();
sidecar.BlockMedia[0].SecureDigital.SCR = new DumpType
sidecar.BlockMedias[0].SecureDigital.SCR = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -264,11 +266,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType();
sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital();
sidecar.BlockMedia[0].SecureDigital.OCR = new DumpType
sidecar.BlockMedias[0].SecureDigital.OCR = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -279,11 +281,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType();
sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard();
sidecar.BlockMedia[0].MultiMediaCard.CID = new DumpType
sidecar.BlockMedias[0].MultiMediaCard.CID = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -294,11 +296,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType();
sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard();
sidecar.BlockMedia[0].MultiMediaCard.CSD = new DumpType
sidecar.BlockMedias[0].MultiMediaCard.CSD = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -309,11 +311,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType();
sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard();
sidecar.BlockMedia[0].MultiMediaCard.OCR = new DumpType
sidecar.BlockMedias[0].MultiMediaCard.OCR = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -324,11 +326,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType();
sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard();
sidecar.BlockMedia[0].MultiMediaCard.ExtendedCSD = new DumpType
sidecar.BlockMedias[0].MultiMediaCard.ExtendedCSD = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -339,11 +341,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].USB ??= new USBType();
sidecar.BlockMedias[0].Usb ??= new Usb();
sidecar.BlockMedia[0].USB.Descriptors = new DumpType
sidecar.BlockMedias[0].Usb.Descriptors = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -354,11 +356,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].SCSI ??= new SCSIType();
sidecar.BlockMedias[0].SCSI ??= new SCSI();
sidecar.BlockMedia[0].SCSI.ModeSense = new DumpType
sidecar.BlockMedias[0].SCSI.ModeSense = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -369,11 +371,11 @@ public sealed partial class Sidecar
if(errno != ErrorNumber.NoError)
break;
sidecar.BlockMedia[0].SCSI ??= new SCSIType();
sidecar.BlockMedias[0].SCSI ??= new SCSI();
sidecar.BlockMedia[0].SCSI.ModeSense10 = new DumpType
sidecar.BlockMedias[0].SCSI.ModeSense10 = new Dump
{
Checksums = Checksum.GetChecksums(buffer).ToArray(),
Checksums = Checksum.GetChecksums(buffer),
Size = (ulong)buffer.Length
};
@@ -384,7 +386,7 @@ public sealed partial class Sidecar
// If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum.
if(image.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") &&
filterId == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
sidecar.BlockMedia[0].ContentChecksums = sidecar.BlockMedia[0].Checksums;
sidecar.BlockMedias[0].ContentChecksums = sidecar.BlockMedias[0].Checksums;
else
{
UpdateStatus(Localization.Core.Hashing_sectors);
@@ -448,42 +450,40 @@ public sealed partial class Sidecar
// For fast debugging, skip checksum
//skipImageChecksum:
List<ChecksumType> cntChecksums = contentChkWorker.End();
sidecar.BlockMedia[0].ContentChecksums = cntChecksums.ToArray();
sidecar.BlockMedias[0].ContentChecksums = contentChkWorker.End();
EndProgress2();
}
(string type, string subType) diskType = MediaType.MediaTypeToString(image.Info.MediaType);
sidecar.BlockMedia[0].DiskType = diskType.type;
sidecar.BlockMedia[0].DiskSubType = diskType.subType;
sidecar.BlockMedias[0].MediaType = diskType.type;
sidecar.BlockMedias[0].MediaSubType = diskType.subType;
Statistics.AddMedia(image.Info.MediaType, false);
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(image.Info.MediaType);
sidecar.BlockMedias[0].Dimensions = Dimensions.DimensionsFromMediaType(image.Info.MediaType);
sidecar.BlockMedia[0].LogicalBlocks = image.Info.Sectors;
sidecar.BlockMedia[0].LogicalBlockSize = image.Info.SectorSize;
sidecar.BlockMedias[0].LogicalBlocks = image.Info.Sectors;
sidecar.BlockMedias[0].LogicalBlockSize = image.Info.SectorSize;
// TODO: Detect it
sidecar.BlockMedia[0].PhysicalBlockSize = image.Info.SectorSize;
sidecar.BlockMedias[0].PhysicalBlockSize = image.Info.SectorSize;
if(image is ITapeImage { IsTape: true } tapeImage)
{
List<TapePartitionType> tapePartitions = new();
List<TapePartition> tapePartitions = new();
foreach(TapePartition tapePartition in tapeImage.TapePartitions)
foreach(CommonTypes.Structs.TapePartition tapePartition in tapeImage.TapePartitions)
{
var thisPartition = new TapePartitionType
var thisPartition = new TapePartition
{
Image = sidecar.BlockMedia[0].Image,
Image = sidecar.BlockMedias[0].Image,
Sequence = tapePartition.Number,
StartBlock = tapePartition.FirstBlock,
EndBlock = tapePartition.LastBlock
};
if(tapeImage.TapePartitions.Count == 1)
thisPartition.Checksums = sidecar.BlockMedia[0].ContentChecksums;
thisPartition.Checksums = sidecar.BlockMedias[0].ContentChecksums;
else
{
UpdateStatus(string.Format(Localization.Core.Hashing_partition_0, tapePartition.Number));
@@ -560,23 +560,22 @@ public sealed partial class Sidecar
// For fast debugging, skip checksum
//skipImageChecksum:
List<ChecksumType> partitionChecksums = tapePartitionChk.End();
thisPartition.Checksums = partitionChecksums.ToArray();
thisPartition.Checksums = tapePartitionChk.End();
EndProgress2();
}
List<TapeFileType> filesInPartition = new();
List<TapeFile> filesInPartition = new();
foreach(TapeFile tapeFile in tapeImage.Files.Where(f => f.Partition == tapePartition.Number))
foreach(CommonTypes.Structs.TapeFile tapeFile in
tapeImage.Files.Where(f => f.Partition == tapePartition.Number))
{
var thisFile = new TapeFileType
var thisFile = new TapeFile
{
Sequence = tapeFile.File,
StartBlock = tapeFile.FirstBlock,
EndBlock = tapeFile.LastBlock,
Image = sidecar.BlockMedia[0].Image,
Image = sidecar.BlockMedias[0].Image,
Size = 0,
BlockSize = 0
};
@@ -666,9 +665,7 @@ public sealed partial class Sidecar
// For fast debugging, skip checksum
//skipImageChecksum:
List<ChecksumType> fileChecksums = tapeFileChk.End();
thisFile.Checksums = fileChecksums.ToArray();
thisFile.Checksums = tapeFileChk.End();
EndProgress2();
}
@@ -676,11 +673,11 @@ public sealed partial class Sidecar
filesInPartition.Add(thisFile);
}
thisPartition.File = filesInPartition.ToArray();
thisPartition.File = filesInPartition;
tapePartitions.Add(thisPartition);
}
sidecar.BlockMedia[0].TapeInformation = tapePartitions.ToArray();
sidecar.BlockMedias[0].TapeInformation = tapePartitions;
}
UpdateStatus(Localization.Core.Checking_filesystems);
@@ -691,28 +688,26 @@ public sealed partial class Sidecar
List<Partition> partitions = Partitions.GetAll(image);
Partitions.AddSchemesToStats(partitions);
sidecar.BlockMedia[0].FileSystemInformation = new PartitionType[1];
sidecar.BlockMedias[0].FileSystemInformation = new List<CommonTypes.AaruMetadata.Partition>();
if(partitions.Count > 0)
{
sidecar.BlockMedia[0].FileSystemInformation = new PartitionType[partitions.Count];
for(int i = 0; i < partitions.Count; i++)
foreach(Partition partition in partitions)
{
if(_aborted)
return;
sidecar.BlockMedia[0].FileSystemInformation[i] = new PartitionType
var fsInfo = new CommonTypes.AaruMetadata.Partition
{
Description = partitions[i].Description,
EndSector = partitions[i].End,
Name = partitions[i].Name,
Sequence = (uint)partitions[i].Sequence,
StartSector = partitions[i].Start,
Type = partitions[i].Type
Description = partition.Description,
EndSector = partition.End,
Name = partition.Name,
Sequence = (uint)partition.Sequence,
StartSector = partition.Start,
Type = partition.Type
};
List<FileSystemType> lstFs = new();
List<FileSystem> lstFs = new();
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
@@ -720,23 +715,23 @@ public sealed partial class Sidecar
if(_aborted)
return;
if(!plugin.Identify(image, partitions[i]))
if(!plugin.Identify(image, partition))
continue;
if(plugin is IReadOnlyFilesystem fsPlugin &&
fsPlugin.Mount(image, partitions[i], encoding, null, null) == ErrorNumber.NoError)
fsPlugin.Mount(image, partition, encoding, null, null) == ErrorNumber.NoError)
{
UpdateStatus(string.Format(Localization.Core.Mounting_0, fsPlugin.XmlFsType.Type));
UpdateStatus(string.Format(Localization.Core.Mounting_0, fsPlugin.Metadata.Type));
fsPlugin.XmlFsType.Contents = Files(fsPlugin);
fsPlugin.Metadata.Contents = Files(fsPlugin);
fsPlugin.Unmount();
}
else
plugin.GetInformation(image, partitions[i], out _, encoding);
plugin.GetInformation(image, partition, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
lstFs.Add(plugin.Metadata);
Statistics.AddFilesystem(plugin.Metadata.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -746,7 +741,9 @@ public sealed partial class Sidecar
}
if(lstFs.Count > 0)
sidecar.BlockMedia[0].FileSystemInformation[i].FileSystems = lstFs.ToArray();
fsInfo.FileSystems = lstFs;
sidecar.BlockMedias[0].FileSystemInformation.Add(fsInfo);
}
}
else
@@ -754,7 +751,7 @@ public sealed partial class Sidecar
if(_aborted)
return;
sidecar.BlockMedia[0].FileSystemInformation[0] = new PartitionType
var fsInfo = new CommonTypes.AaruMetadata.Partition
{
StartSector = 0,
EndSector = image.Info.Sectors - 1
@@ -767,7 +764,7 @@ public sealed partial class Sidecar
Size = image.Info.Sectors * image.Info.SectorSize
};
List<FileSystemType> lstFs = new();
List<FileSystem> lstFs = new();
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
@@ -781,17 +778,17 @@ public sealed partial class Sidecar
if(plugin is IReadOnlyFilesystem fsPlugin &&
fsPlugin.Mount(image, wholePart, encoding, null, null) == ErrorNumber.NoError)
{
UpdateStatus(string.Format(Localization.Core.Mounting_0, fsPlugin.XmlFsType.Type));
UpdateStatus(string.Format(Localization.Core.Mounting_0, fsPlugin.Metadata.Type));
fsPlugin.XmlFsType.Contents = Files(fsPlugin);
fsPlugin.Metadata.Contents = Files(fsPlugin);
fsPlugin.Unmount();
}
else
plugin.GetInformation(image, wholePart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
lstFs.Add(plugin.Metadata);
Statistics.AddFilesystem(plugin.Metadata.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -801,7 +798,9 @@ public sealed partial class Sidecar
}
if(lstFs.Count > 0)
sidecar.BlockMedia[0].FileSystemInformation[0].FileSystems = lstFs.ToArray();
fsInfo.FileSystems = lstFs;
sidecar.BlockMedias[0].FileSystemInformation.Add(fsInfo);
}
UpdateStatus(Localization.Core.Saving_metadata);
@@ -809,12 +808,9 @@ public sealed partial class Sidecar
if(image.Info.Cylinders > 0 &&
image.Info is { Heads: > 0, SectorsPerTrack: > 0 })
{
sidecar.BlockMedia[0].CylindersSpecified = true;
sidecar.BlockMedia[0].HeadsSpecified = true;
sidecar.BlockMedia[0].SectorsPerTrackSpecified = true;
sidecar.BlockMedia[0].Cylinders = image.Info.Cylinders;
sidecar.BlockMedia[0].Heads = (ushort)image.Info.Heads;
sidecar.BlockMedia[0].SectorsPerTrack = image.Info.SectorsPerTrack;
sidecar.BlockMedias[0].Cylinders = image.Info.Cylinders;
sidecar.BlockMedias[0].Heads = (ushort)image.Info.Heads;
sidecar.BlockMedias[0].SectorsPerTrack = image.Info.SectorsPerTrack;
}
if(image.Info.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY))
@@ -830,28 +826,21 @@ public sealed partial class Sidecar
ataId.Value.CurrentHeads > 0 &&
ataId.Value.CurrentSectorsPerTrack > 0)
{
sidecar.BlockMedia[0].CylindersSpecified = true;
sidecar.BlockMedia[0].HeadsSpecified = true;
sidecar.BlockMedia[0].SectorsPerTrackSpecified = true;
sidecar.BlockMedia[0].Cylinders = ataId.Value.CurrentCylinders;
sidecar.BlockMedia[0].Heads = ataId.Value.CurrentHeads;
sidecar.BlockMedia[0].SectorsPerTrack = ataId.Value.CurrentSectorsPerTrack;
sidecar.BlockMedias[0].Cylinders = ataId.Value.CurrentCylinders;
sidecar.BlockMedias[0].Heads = ataId.Value.CurrentHeads;
sidecar.BlockMedias[0].SectorsPerTrack = ataId.Value.CurrentSectorsPerTrack;
}
else if(ataId.Value.Cylinders > 0 &&
ataId.Value.Heads > 0 &&
ataId.Value.SectorsPerTrack > 0)
{
sidecar.BlockMedia[0].CylindersSpecified = true;
sidecar.BlockMedia[0].HeadsSpecified = true;
sidecar.BlockMedia[0].SectorsPerTrackSpecified = true;
sidecar.BlockMedia[0].Cylinders = ataId.Value.Cylinders;
sidecar.BlockMedia[0].Heads = ataId.Value.Heads;
sidecar.BlockMedia[0].SectorsPerTrack = ataId.Value.SectorsPerTrack;
sidecar.BlockMedias[0].Cylinders = ataId.Value.Cylinders;
sidecar.BlockMedias[0].Heads = ataId.Value.Heads;
sidecar.BlockMedias[0].SectorsPerTrack = ataId.Value.SectorsPerTrack;
}
}
if(image.DumpHardware != null)
sidecar.BlockMedia[0].DumpHardwareArray = image.DumpHardware.ToArray();
sidecar.BlockMedias[0].DumpHardware = image.DumpHardware;
// TODO: This is more of a hack, redo it planned for >4.0
string trkFormat = null;
@@ -1009,24 +998,24 @@ public sealed partial class Sidecar
(image.Info.Heads == 1 && scpImage.Header.heads is 1 or 2))
if(scpImage.Header.end + 1 >= image.Info.Cylinders)
{
List<BlockTrackType> scpBlockTrackTypes = new();
ulong currentSector = 0;
Stream scpStream = scpFilter.GetDataForkStream();
List<BlockTrack> scpBlockTrackTypes = new();
ulong currentSector = 0;
Stream scpStream = scpFilter.GetDataForkStream();
for(byte t = scpImage.Header.start; t <= scpImage.Header.end; t++)
{
if(_aborted)
return;
var scpBlockTrackType = new BlockTrackType
var scpBlockTrackType = new BlockTrack
{
Cylinder = t / image.Info.Heads,
Head = (ushort)(t % image.Info.Heads),
Image = new ImageType
Image = new Image
{
format = scpImage.Format,
Format = scpImage.Format,
Value = Path.GetFileName(scpFilePath),
offset = scpImage.Header.offsets[t]
Offset = scpImage.Header.offsets[t]
}
};
@@ -1049,14 +1038,14 @@ public sealed partial class Sidecar
scpStream.Position = scpImage.Header.offsets[t];
scpStream.EnsureRead(trackContents, 0, trackContents.Length);
scpBlockTrackType.Size = (ulong)trackContents.Length;
scpBlockTrackType.Checksums = Checksum.GetChecksums(trackContents).ToArray();
scpBlockTrackType.Checksums = Checksum.GetChecksums(trackContents);
}
scpBlockTrackTypes.Add(scpBlockTrackType);
}
sidecar.BlockMedia[0].Track = scpBlockTrackTypes.OrderBy(t => t.Cylinder).
ThenBy(t => t.Head).ToArray();
sidecar.BlockMedias[0].Track = scpBlockTrackTypes.OrderBy(t => t.Cylinder).
ThenBy(t => t.Head).ToList();
}
else
AaruConsole.
@@ -1115,7 +1104,7 @@ public sealed partial class Sidecar
if(kfImage.Info.Heads == image.Info.Heads)
if(kfImage.Info.Cylinders >= image.Info.Cylinders)
{
List<BlockTrackType> kfBlockTrackTypes = new();
List<BlockTrack> kfBlockTrackTypes = new();
ulong currentSector = 0;
@@ -1124,18 +1113,18 @@ public sealed partial class Sidecar
if(_aborted)
return;
var kfBlockTrackType = new BlockTrackType
var kfBlockTrackType = new BlockTrack
{
Cylinder = kvp.Key / image.Info.Heads,
Head = (ushort)(kvp.Key % image.Info.Heads),
Image = new ImageType
Image = new Image
{
format = kfImage.Format,
Format = kfImage.Format,
Value = kfDir
? Path.
Combine(Path.GetFileName(Path.GetDirectoryName(kvp.Value.BasePath)),
kvp.Value.Filename) : kvp.Value.Filename,
offset = 0
Offset = 0
}
};
@@ -1154,13 +1143,13 @@ public sealed partial class Sidecar
kfStream.Position = 0;
kfStream.EnsureRead(trackContents, 0, trackContents.Length);
kfBlockTrackType.Size = (ulong)trackContents.Length;
kfBlockTrackType.Checksums = Checksum.GetChecksums(trackContents).ToArray();
kfBlockTrackType.Checksums = Checksum.GetChecksums(trackContents);
kfBlockTrackTypes.Add(kfBlockTrackType);
}
sidecar.BlockMedia[0].Track = kfBlockTrackTypes.OrderBy(t => t.Cylinder).
ThenBy(t => t.Head).ToArray();
sidecar.BlockMedias[0].Track = kfBlockTrackTypes.OrderBy(t => t.Cylinder).
ThenBy(t => t.Head).ToList();
}
else
AaruConsole.
@@ -1202,22 +1191,22 @@ public sealed partial class Sidecar
if(image.Info.Heads == dfiImage.Info.Heads)
if(dfiImage.Info.Cylinders >= image.Info.Cylinders)
{
List<BlockTrackType> dfiBlockTrackTypes = new();
ulong currentSector = 0;
Stream dfiStream = dfiFilter.GetDataForkStream();
List<BlockTrack> dfiBlockTrackTypes = new();
ulong currentSector = 0;
Stream dfiStream = dfiFilter.GetDataForkStream();
foreach(int t in dfiImage.TrackOffsets.Keys)
{
if(_aborted)
return;
var dfiBlockTrackType = new BlockTrackType
var dfiBlockTrackType = new BlockTrack
{
Cylinder = (uint)(t / image.Info.Heads),
Head = (ushort)(t % image.Info.Heads),
Image = new ImageType
Image = new Image
{
format = dfiImage.Format,
Format = dfiImage.Format,
Value = Path.GetFileName(dfiFilePath)
}
};
@@ -1235,18 +1224,18 @@ public sealed partial class Sidecar
if(dfiImage.TrackOffsets.TryGetValue(t, out long offset) &&
dfiImage.TrackLengths.TryGetValue(t, out long length))
{
dfiBlockTrackType.Image.offset = (ulong)offset;
dfiBlockTrackType.Image.Offset = (ulong)offset;
byte[] trackContents = new byte[length];
dfiStream.Position = offset;
dfiStream.EnsureRead(trackContents, 0, trackContents.Length);
dfiBlockTrackType.Size = (ulong)trackContents.Length;
dfiBlockTrackType.Checksums = Checksum.GetChecksums(trackContents).ToArray();
dfiBlockTrackType.Checksums = Checksum.GetChecksums(trackContents);
}
dfiBlockTrackTypes.Add(dfiBlockTrackType);
}
sidecar.BlockMedia[0].Track = dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray();
sidecar.BlockMedias[0].Track = dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToList();
}
else
AaruConsole.

View File

@@ -32,8 +32,8 @@
using System.Collections.Generic;
using System.IO;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.Helpers;
using Schemas;
namespace Aaru.Core;
@@ -44,37 +44,35 @@ public sealed partial class Sidecar
/// <param name="files">List of files</param>
/// <param name="folderName">Dump path</param>
/// <param name="blockSize">Expected block size in bytes</param>
public CICMMetadataType BlockTape(string folderName, List<string> files, uint blockSize)
public Metadata BlockTape(string folderName, List<string> files, uint blockSize)
{
_sidecar = new CICMMetadataType
_sidecar = new Metadata
{
BlockMedia = new[]
BlockMedias = new List<BlockMedia>
{
new BlockMediaType
new()
{
Image = new ImageType
Image = new Image
{
format = "Directory",
offsetSpecified = false,
Value = folderName
Format = "Directory",
Value = folderName
},
Sequence = new SequenceType
Sequence = new Sequence
{
MediaTitle = folderName,
Title = folderName,
MediaSequence = 1,
TotalMedia = 1
},
PhysicalBlockSize = blockSize,
LogicalBlockSize = blockSize,
TapeInformation = new[]
TapeInformation = new List<TapePartition>
{
new TapePartitionType
new()
{
Image = new ImageType
Image = new Image
{
format = "Directory",
offsetSpecified = false,
Value = folderName
Format = "Directory",
Value = folderName
}
}
}
@@ -85,10 +83,10 @@ public sealed partial class Sidecar
if(_aborted)
return _sidecar;
ulong currentBlock = 0;
ulong totalSize = 0;
var tapeWorker = new Checksum();
List<TapeFileType> tapeFiles = new();
ulong currentBlock = 0;
ulong totalSize = 0;
var tapeWorker = new Checksum();
List<TapeFile> tapeFiles = new();
UpdateStatus(Localization.Core.Hashing_files);
@@ -100,12 +98,12 @@ public sealed partial class Sidecar
_fs = new FileStream(files[i], FileMode.Open, FileAccess.Read);
var fileWorker = new Checksum();
var tapeFile = new TapeFileType
var tapeFile = new TapeFile
{
Image = new ImageType
Image = new Image
{
format = "Raw disk image (sector by sector copy)",
offset = 0,
Format = "Raw disk image (sector by sector copy)",
Offset = 0,
Value = Path.GetFileName(files[i])
},
Size = (ulong)_fs.Length,
@@ -159,92 +157,92 @@ public sealed partial class Sidecar
tapeFile.EndBlock = tapeFile.StartBlock + sectors - 1;
currentBlock += sectors;
totalSize += (ulong)_fs.Length;
tapeFile.Checksums = fileWorker.End().ToArray();
tapeFile.Checksums = fileWorker.End();
tapeFiles.Add(tapeFile);
EndProgress2();
}
UpdateStatus("Setting metadata...");
_sidecar.BlockMedia[0].Checksums = tapeWorker.End().ToArray();
_sidecar.BlockMedia[0].ContentChecksums = _sidecar.BlockMedia[0].Checksums;
_sidecar.BlockMedia[0].Size = totalSize;
_sidecar.BlockMedia[0].LogicalBlocks = currentBlock;
_sidecar.BlockMedia[0].TapeInformation[0].EndBlock = currentBlock - 1;
_sidecar.BlockMedia[0].TapeInformation[0].Size = totalSize;
_sidecar.BlockMedia[0].TapeInformation[0].Checksums = _sidecar.BlockMedia[0].Checksums;
_sidecar.BlockMedia[0].TapeInformation[0].File = tapeFiles.ToArray();
_sidecar.BlockMedias[0].Checksums = tapeWorker.End();
_sidecar.BlockMedias[0].ContentChecksums = _sidecar.BlockMedias[0].Checksums;
_sidecar.BlockMedias[0].Size = totalSize;
_sidecar.BlockMedias[0].LogicalBlocks = currentBlock;
_sidecar.BlockMedias[0].TapeInformation[0].EndBlock = currentBlock - 1;
_sidecar.BlockMedias[0].TapeInformation[0].Size = totalSize;
_sidecar.BlockMedias[0].TapeInformation[0].Checksums = _sidecar.BlockMedias[0].Checksums;
_sidecar.BlockMedias[0].TapeInformation[0].File = tapeFiles;
// This is purely for convenience, as typically these kind of data represents QIC tapes
if(blockSize == 512)
{
_sidecar.BlockMedia[0].DiskType = "Quarter-inch cartridge";
_sidecar.BlockMedias[0].MediaType = "Quarter-inch cartridge";
switch(totalSize)
{
case <= 20 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-11";
_sidecar.BlockMedias[0].MediaSubType = "QIC-11";
break;
case <= 40 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-40";
_sidecar.BlockMedias[0].MediaSubType = "QIC-40";
break;
case <= 60 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-24";
_sidecar.BlockMedias[0].MediaSubType = "QIC-24";
break;
case <= 80 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-80";
_sidecar.BlockMedias[0].MediaSubType = "QIC-80";
break;
case <= 120 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-120";
_sidecar.BlockMedias[0].MediaSubType = "QIC-120";
break;
case <= 150 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-150";
_sidecar.BlockMedias[0].MediaSubType = "QIC-150";
break;
case <= 320 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-320";
_sidecar.BlockMedias[0].MediaSubType = "QIC-320";
break;
case <= 340 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-3010";
_sidecar.BlockMedias[0].MediaSubType = "QIC-3010";
break;
case <= 525 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-525";
_sidecar.BlockMedias[0].MediaSubType = "QIC-525";
break;
case <= 670 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-3020";
_sidecar.BlockMedias[0].MediaSubType = "QIC-3020";
break;
case <= 1200 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-3080";
_sidecar.BlockMedias[0].MediaSubType = "QIC-3080";
break;
case <= 1350 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-1350";
_sidecar.BlockMedias[0].MediaSubType = "QIC-1350";
break;
case <= (long)4000 * 1048576:
_sidecar.BlockMedia[0].DiskSubType = "QIC-3095";
_sidecar.BlockMedias[0].MediaSubType = "QIC-3095";
break;
default:
_sidecar.BlockMedia[0].DiskType = "Unknown tape";
_sidecar.BlockMedia[0].DiskSubType = "Unknown tape";
_sidecar.BlockMedias[0].MediaType = "Unknown tape";
_sidecar.BlockMedias[0].MediaSubType = "Unknown tape";
break;
}
}
else
{
_sidecar.BlockMedia[0].DiskType = "Unknown tape";
_sidecar.BlockMedia[0].DiskSubType = "Unknown tape";
_sidecar.BlockMedias[0].MediaType = "Unknown tape";
_sidecar.BlockMedias[0].MediaSubType = "Unknown tape";
}
return _sidecar;

View File

@@ -34,27 +34,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Console;
using Schemas;
namespace Aaru.Core;
public sealed partial class Sidecar
{
FilesystemContentsType Files(IReadOnlyFilesystem filesystem)
FilesystemContents Files(IReadOnlyFilesystem filesystem)
{
var contents = new FilesystemContentsType();
var contents = new FilesystemContents();
ErrorNumber ret = filesystem.ReadDir("/", out List<string> dirents);
if(ret != ErrorNumber.NoError)
return null;
List<DirectoryType> directories = new();
List<ContentsFileType> files = new();
List<Directory> directories = new();
List<ContentsFile> files = new();
foreach(string dirent in dirents)
{
@@ -78,86 +78,40 @@ public sealed partial class Sidecar
}
if(files.Count > 0)
contents.File = files.OrderBy(f => f.name).ToArray();
contents.Files = files.OrderBy(f => f.Name).ToList();
if(directories.Count > 0)
contents.Directory = directories.OrderBy(d => d.name).ToArray();
contents.Directories = directories.OrderBy(d => d.Name).ToList();
return contents;
}
DirectoryType SidecarDirectory(IReadOnlyFilesystem filesystem, string path, string filename, FileEntryInfo stat)
Directory SidecarDirectory(IReadOnlyFilesystem filesystem, string path, string filename, FileEntryInfo stat)
{
var directory = new DirectoryType();
if(stat.AccessTimeUtc.HasValue)
var directory = new Directory
{
directory.accessTime = stat.AccessTimeUtc.Value;
directory.accessTimeSpecified = true;
}
directory.attributes = (ulong)stat.Attributes;
if(stat.BackupTimeUtc.HasValue)
{
directory.backupTime = stat.BackupTimeUtc.Value;
directory.backupTimeSpecified = true;
}
if(stat.CreationTimeUtc.HasValue)
{
directory.creationTime = stat.CreationTimeUtc.Value;
directory.creationTimeSpecified = true;
}
if(stat.DeviceNo.HasValue)
{
directory.deviceNumber = stat.DeviceNo.Value;
directory.deviceNumberSpecified = true;
}
directory.inode = stat.Inode;
if(stat.LastWriteTimeUtc.HasValue)
{
directory.lastWriteTime = stat.LastWriteTimeUtc.Value;
directory.lastWriteTimeSpecified = true;
}
directory.links = stat.Links;
directory.name = filename;
if(stat.GID.HasValue)
{
directory.posixGroupId = stat.GID.Value;
directory.posixGroupIdSpecified = true;
}
if(stat.Mode.HasValue)
{
directory.posixMode = stat.Mode.Value;
directory.posixModeSpecified = true;
}
if(stat.UID.HasValue)
{
directory.posixUserId = stat.UID.Value;
directory.posixUserIdSpecified = true;
}
if(stat.StatusChangeTimeUtc.HasValue)
{
directory.statusChangeTime = stat.StatusChangeTimeUtc.Value;
directory.statusChangeTimeSpecified = true;
}
AccessTime = stat.AccessTimeUtc,
Attributes = (ulong)stat.Attributes,
BackupTime = stat.BackupTimeUtc,
CreationTime = stat.CreationTimeUtc,
DeviceNumber = stat.DeviceNo,
Inode = stat.Inode,
LastWriteTime = stat.LastWriteTimeUtc,
Links = stat.Links,
Name = filename,
PosixGroupId = stat.GID,
PosixMode = stat.Mode,
PosixUserId = stat.UID,
StatusChangeTime = stat.StatusChangeTimeUtc
};
ErrorNumber ret = filesystem.ReadDir(path + "/" + filename, out List<string> dirents);
if(ret != ErrorNumber.NoError)
return null;
List<DirectoryType> directories = new();
List<ContentsFileType> files = new();
List<Directory> directories = new();
List<ContentsFile> files = new();
foreach(string dirent in dirents)
{
@@ -181,80 +135,35 @@ public sealed partial class Sidecar
}
if(files.Count > 0)
directory.File = files.OrderBy(f => f.name).ToArray();
directory.Files = files.OrderBy(f => f.Name).ToList();
if(directories.Count > 0)
directory.Directory = directories.OrderBy(d => d.name).ToArray();
directory.Directories = directories.OrderBy(d => d.Name).ToList();
return directory;
}
ContentsFileType SidecarFile(IReadOnlyFilesystem filesystem, string path, string filename, FileEntryInfo stat)
ContentsFile SidecarFile(IReadOnlyFilesystem filesystem, string path, string filename, FileEntryInfo stat)
{
var file = new ContentsFileType();
var fileChkWorker = new Checksum();
if(stat.AccessTimeUtc.HasValue)
var file = new ContentsFile
{
file.accessTime = stat.AccessTimeUtc.Value;
file.accessTimeSpecified = true;
}
file.attributes = (ulong)stat.Attributes;
if(stat.BackupTimeUtc.HasValue)
{
file.backupTime = stat.BackupTimeUtc.Value;
file.backupTimeSpecified = true;
}
if(stat.CreationTimeUtc.HasValue)
{
file.creationTime = stat.CreationTimeUtc.Value;
file.creationTimeSpecified = true;
}
if(stat.DeviceNo.HasValue)
{
file.deviceNumber = stat.DeviceNo.Value;
file.deviceNumberSpecified = true;
}
file.inode = stat.Inode;
if(stat.LastWriteTimeUtc.HasValue)
{
file.lastWriteTime = stat.LastWriteTimeUtc.Value;
file.lastWriteTimeSpecified = true;
}
file.length = (ulong)stat.Length;
file.links = stat.Links;
file.name = filename;
if(stat.GID.HasValue)
{
file.posixGroupId = stat.GID.Value;
file.posixGroupIdSpecified = true;
}
if(stat.Mode.HasValue)
{
file.posixMode = stat.Mode.Value;
file.posixModeSpecified = true;
}
if(stat.UID.HasValue)
{
file.posixUserId = stat.UID.Value;
file.posixUserIdSpecified = true;
}
if(stat.StatusChangeTimeUtc.HasValue)
{
file.statusChangeTime = stat.StatusChangeTimeUtc.Value;
file.statusChangeTimeSpecified = true;
}
AccessTime = stat.AccessTimeUtc,
Attributes = (ulong)stat.Attributes,
BackupTime = stat.BackupTimeUtc,
CreationTime = stat.CreationTimeUtc,
DeviceNumber = stat.DeviceNo,
Inode = stat.Inode,
LastWriteTime = stat.LastWriteTimeUtc,
Length = (ulong)stat.Length,
Links = stat.Links,
Name = filename,
PosixGroupId = stat.GID,
PosixMode = stat.Mode,
PosixUserId = stat.UID,
StatusChangeTime = stat.StatusChangeTimeUtc
};
byte[] data = Array.Empty<byte>();
@@ -288,7 +197,7 @@ public sealed partial class Sidecar
EndProgress2();
file.Checksums = fileChkWorker.End().ToArray();
file.Checksums = fileChkWorker.End();
}
else
file.Checksums = _emptyChecksums;
@@ -298,7 +207,7 @@ public sealed partial class Sidecar
if(ret != ErrorNumber.NoError)
return file;
List<ExtendedAttributeType> xattrTypes = new();
List<ExtendedAttribute> xattrTypes = new();
foreach(string xattr in xattrs)
{
@@ -310,16 +219,16 @@ public sealed partial class Sidecar
var xattrChkWorker = new Checksum();
xattrChkWorker.Update(data);
xattrTypes.Add(new ExtendedAttributeType
xattrTypes.Add(new ExtendedAttribute
{
Checksums = xattrChkWorker.End().ToArray(),
length = (ulong)data.Length,
name = xattr
Checksums = xattrChkWorker.End(),
Length = (ulong)data.Length,
Name = xattr
});
}
if(xattrTypes.Count > 0)
file.ExtendedAttributes = xattrTypes.OrderBy(x => x.name).ToArray();
file.ExtendedAttributes = xattrTypes.OrderBy(x => x.Name).ToList();
return file;
}

View File

@@ -35,8 +35,8 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Interfaces;
using Schemas;
namespace Aaru.Core;
@@ -53,18 +53,17 @@ public sealed partial class Sidecar
/// <param name="sidecar">Metadata sidecar</param>
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
static void LinearMedia(IByteAddressableImage image, Guid filterId, string imagePath, FileInfo fi,
PluginBase plugins, List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar,
Encoding encoding) => sidecar.LinearMedia = new[]
PluginBase plugins, List<CommonTypes.AaruMetadata.Checksum> imgChecksums,
ref Metadata sidecar, Encoding encoding) => sidecar.LinearMedias = new List<LinearMedia>
{
new LinearMediaType
new()
{
Checksums = imgChecksums.ToArray(),
Image = new ImageType
Checksums = imgChecksums,
Image = new Image
{
format = image.Format,
offset = 0,
offsetSpecified = true,
Value = Path.GetFileName(imagePath)
Format = image.Format,
Offset = 0,
Value = Path.GetFileName(imagePath)
},
Size = image.Info.Sectors
}

View File

@@ -36,18 +36,19 @@ using System.IO;
using System.Linq;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Metadata;
using Aaru.CommonTypes.Structs;
using Aaru.Core.Devices.Dumping;
using Aaru.Decoders.CD;
using Aaru.Decoders.DVD;
using Schemas;
using DMI = Aaru.Decoders.Xbox.DMI;
using Dump = Aaru.Core.Devices.Dumping.Dump;
using MediaType = Aaru.CommonTypes.MediaType;
using Partition = Aaru.CommonTypes.Partition;
using Session = Aaru.CommonTypes.Structs.Session;
using TrackType = Schemas.TrackType;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
namespace Aaru.Core;
@@ -63,27 +64,26 @@ public sealed partial class Sidecar
/// <param name="sidecar">Metadata sidecar</param>
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
void OpticalDisc(IOpticalMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar, Encoding encoding)
{
if(_aborted)
return;
sidecar.OpticalDisc = new[]
sidecar.OpticalDiscs = new List<OpticalDisc>
{
new OpticalDiscType
new()
{
Checksums = imgChecksums.ToArray(),
Image = new ImageType
Checksums = imgChecksums,
Image = new Image
{
format = image.Format,
offset = 0,
offsetSpecified = true,
Value = Path.GetFileName(imagePath)
Format = image.Format,
Offset = 0,
Value = Path.GetFileName(imagePath)
},
Size = (ulong)fi.Length,
Sequence = new SequenceType
Sequence = new Sequence
{
MediaTitle = image.Info.MediaTitle
Title = image.Info.MediaTitle
}
}
};
@@ -91,13 +91,13 @@ public sealed partial class Sidecar
if(image.Info.MediaSequence != 0 &&
image.Info.LastMediaSequence != 0)
{
sidecar.OpticalDisc[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
sidecar.OpticalDisc[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
sidecar.OpticalDiscs[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
sidecar.OpticalDiscs[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
}
else
{
sidecar.OpticalDisc[0].Sequence.MediaSequence = 1;
sidecar.OpticalDisc[0].Sequence.TotalMedia = 1;
sidecar.OpticalDiscs[0].Sequence.MediaSequence = 1;
sidecar.OpticalDiscs[0].Sequence.TotalMedia = 1;
}
MediaType dskType = image.Info.MediaType;
@@ -134,7 +134,7 @@ public sealed partial class Sidecar
{
dskType = MediaType.XGD;
sidecar.OpticalDisc[0].Dimensions = new DimensionsType
sidecar.OpticalDiscs[0].Dimensions = new DimensionsNew
{
Diameter = 120,
Thickness = 1.2
@@ -144,7 +144,7 @@ public sealed partial class Sidecar
{
dskType = MediaType.XGD2;
sidecar.OpticalDisc[0].Dimensions = new DimensionsType
sidecar.OpticalDiscs[0].Dimensions = new DimensionsNew
{
Diameter = 120,
Thickness = 1.2
@@ -194,29 +194,25 @@ public sealed partial class Sidecar
pfi.Value.DiscSize == DVDSize.OneTwenty)
dskType = MediaType.WOD;
sidecar.OpticalDisc[0].Dimensions = new DimensionsType();
sidecar.OpticalDiscs[0].Dimensions = new DimensionsNew();
if(dskType == MediaType.UMD)
{
sidecar.OpticalDisc[0].Dimensions.Height = 64;
sidecar.OpticalDisc[0].Dimensions.HeightSpecified = true;
sidecar.OpticalDisc[0].Dimensions.Width = 63;
sidecar.OpticalDisc[0].Dimensions.WidthSpecified = true;
sidecar.OpticalDisc[0].Dimensions.Thickness = 4;
sidecar.OpticalDiscs[0].Dimensions.Height = 64;
sidecar.OpticalDiscs[0].Dimensions.Width = 63;
sidecar.OpticalDiscs[0].Dimensions.Thickness = 4;
}
else
switch(pfi.Value.DiscSize)
{
case DVDSize.Eighty:
sidecar.OpticalDisc[0].Dimensions.Diameter = 80;
sidecar.OpticalDisc[0].Dimensions.DiameterSpecified = true;
sidecar.OpticalDisc[0].Dimensions.Thickness = 1.2;
sidecar.OpticalDiscs[0].Dimensions.Diameter = 80;
sidecar.OpticalDiscs[0].Dimensions.Thickness = 1.2;
break;
case DVDSize.OneTwenty:
sidecar.OpticalDisc[0].Dimensions.Diameter = 120;
sidecar.OpticalDisc[0].Dimensions.DiameterSpecified = true;
sidecar.OpticalDisc[0].Dimensions.Thickness = 1.2;
sidecar.OpticalDiscs[0].Dimensions.Diameter = 120;
sidecar.OpticalDiscs[0].Dimensions.Thickness = 1.2;
break;
}
@@ -229,26 +225,26 @@ public sealed partial class Sidecar
try
{
List<Session> sessions = image.Sessions;
sidecar.OpticalDisc[0].Sessions = (uint)(sessions?.Count ?? 1);
sidecar.OpticalDiscs[0].Sessions = (uint)(sessions?.Count ?? 1);
}
catch
{
sidecar.OpticalDisc[0].Sessions = 1;
sidecar.OpticalDiscs[0].Sessions = 1;
}
List<Track> tracks = image.Tracks;
List<TrackType> trksLst = null;
List<Track> tracks = image.Tracks;
List<CommonTypes.AaruMetadata.Track> trksLst = null;
if(tracks != null)
{
sidecar.OpticalDisc[0].Tracks = new uint[1];
sidecar.OpticalDisc[0].Tracks[0] = (uint)tracks.Count;
trksLst = new List<TrackType>();
sidecar.OpticalDiscs[0].Tracks = new uint[1];
sidecar.OpticalDiscs[0].Tracks[0] = (uint)tracks.Count;
trksLst = new List<CommonTypes.AaruMetadata.Track>();
}
if(sidecar.OpticalDisc[0].Dimensions == null &&
image.Info.MediaType != MediaType.Unknown)
sidecar.OpticalDisc[0].Dimensions = Dimensions.DimensionsFromMediaType(image.Info.MediaType);
if(sidecar.OpticalDiscs[0].Dimensions == null &&
image.Info.MediaType != MediaType.Unknown)
sidecar.OpticalDiscs[0].Dimensions = Dimensions.DimensionsFromMediaType(image.Info.MediaType);
if(_aborted)
return;
@@ -270,30 +266,30 @@ public sealed partial class Sidecar
return;
}
var xmlTrk = new TrackType();
var xmlTrk = new CommonTypes.AaruMetadata.Track();
xmlTrk.TrackType1 = trk.Type switch
xmlTrk.Type = trk.Type switch
{
CommonTypes.Enums.TrackType.Audio => TrackTypeTrackType.audio,
CommonTypes.Enums.TrackType.CdMode2Form2 => TrackTypeTrackType.m2f2,
CommonTypes.Enums.TrackType.CdMode2Formless => TrackTypeTrackType.mode2,
CommonTypes.Enums.TrackType.CdMode2Form1 => TrackTypeTrackType.m2f1,
CommonTypes.Enums.TrackType.CdMode1 => TrackTypeTrackType.mode1,
CommonTypes.Enums.TrackType.Data => sidecar.OpticalDisc[0].DiscType switch
TrackType.Audio => CommonTypes.AaruMetadata.TrackType.Audio,
TrackType.CdMode2Form2 => CommonTypes.AaruMetadata.TrackType.Mode2Form2,
TrackType.CdMode2Formless => CommonTypes.AaruMetadata.TrackType.Mode2,
TrackType.CdMode2Form1 => CommonTypes.AaruMetadata.TrackType.Mode2Form1,
TrackType.CdMode1 => CommonTypes.AaruMetadata.TrackType.Mode1,
TrackType.Data => sidecar.OpticalDiscs[0].DiscType switch
{
"BD" => TrackTypeTrackType.bluray,
"DDCD" => TrackTypeTrackType.ddcd,
"DVD" => TrackTypeTrackType.dvd,
"HD DVD" => TrackTypeTrackType.hddvd,
_ => TrackTypeTrackType.mode1
"BD" => CommonTypes.AaruMetadata.TrackType.Bluray,
"DDCD" => CommonTypes.AaruMetadata.TrackType.Ddcd,
"DVD" => CommonTypes.AaruMetadata.TrackType.Dvd,
"HD DVD" => CommonTypes.AaruMetadata.TrackType.HdDvd,
_ => CommonTypes.AaruMetadata.TrackType.Mode1
},
_ => xmlTrk.TrackType1
_ => xmlTrk.Type
};
xmlTrk.Sequence = new TrackSequenceType
xmlTrk.Sequence = new TrackSequence
{
Session = trk.Session,
TrackNumber = trk.Sequence
Session = trk.Session,
Number = trk.Sequence
};
xmlTrk.StartSector = trk.StartSector;
@@ -303,32 +299,29 @@ public sealed partial class Sidecar
idx0 >= 0)
xmlTrk.StartSector = (ulong)idx0;
switch(sidecar.OpticalDisc[0].DiscType)
switch(sidecar.OpticalDiscs[0].DiscType)
{
case "CD":
case "GD":
xmlTrk.StartMSF = LbaToMsf((long)xmlTrk.StartSector);
xmlTrk.EndMSF = LbaToMsf((long)xmlTrk.EndSector);
xmlTrk.StartMsf = LbaToMsf((long)xmlTrk.StartSector);
xmlTrk.EndMsf = LbaToMsf((long)xmlTrk.EndSector);
break;
case "DDCD":
xmlTrk.StartMSF = DdcdLbaToMsf((long)xmlTrk.StartSector);
xmlTrk.EndMSF = DdcdLbaToMsf((long)xmlTrk.EndSector);
xmlTrk.StartMsf = DdcdLbaToMsf((long)xmlTrk.StartSector);
xmlTrk.EndMsf = DdcdLbaToMsf((long)xmlTrk.EndSector);
break;
}
xmlTrk.Image = new ImageType
xmlTrk.Image = new Image
{
Value = Path.GetFileName(trk.File),
format = trk.FileType
Format = trk.FileType
};
if(trk.FileOffset > 0)
{
xmlTrk.Image.offset = trk.FileOffset;
xmlTrk.Image.offsetSpecified = true;
}
xmlTrk.Image.Offset = trk.FileOffset;
xmlTrk.Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * (ulong)trk.RawBytesPerSector;
@@ -346,7 +339,7 @@ public sealed partial class Sidecar
// ...or AppleDouble
filterId == new Guid("1b2165ee-c9df-4b21-bbbb-9e5892b2df4d")))
xmlTrk.Checksums = sidecar.OpticalDisc[0].Checksums;
xmlTrk.Checksums = sidecar.OpticalDiscs[0].Checksums;
else
{
UpdateProgress(Localization.Core.Track_0_of_1, trk.Sequence, tracks.Count);
@@ -372,8 +365,7 @@ public sealed partial class Sidecar
if(sectors - doneSectors >= sectorsToRead)
{
errno = image.ReadSectorsLong(doneSectors, sectorsToRead, xmlTrk.Sequence.TrackNumber,
out sector);
errno = image.ReadSectorsLong(doneSectors, sectorsToRead, xmlTrk.Sequence.Number, out sector);
UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, (long)doneSectors,
(long)(trk.EndSector - trk.StartSector + 1));
@@ -391,7 +383,7 @@ public sealed partial class Sidecar
else
{
errno = image.ReadSectorsLong(doneSectors, (uint)(sectors - doneSectors),
xmlTrk.Sequence.TrackNumber, out sector);
xmlTrk.Sequence.Number, out sector);
UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, (long)doneSectors,
(long)(trk.EndSector - trk.StartSector + 1));
@@ -410,18 +402,16 @@ public sealed partial class Sidecar
trkChkWorker.Update(sector);
}
List<ChecksumType> trkChecksums = trkChkWorker.End();
xmlTrk.Checksums = trkChecksums.ToArray();
xmlTrk.Checksums = trkChkWorker.End();
EndProgress2();
}
if(trk.SubchannelType != TrackSubchannelType.None)
{
xmlTrk.SubChannel = new SubChannelType
xmlTrk.SubChannel = new SubChannel
{
Image = new ImageType
Image = new Image
{
Value = trk.SubchannelFile
},
@@ -434,26 +424,23 @@ public sealed partial class Sidecar
{
case TrackSubchannelType.Packed:
case TrackSubchannelType.PackedInterleaved:
xmlTrk.SubChannel.Image.format = "rw";
xmlTrk.SubChannel.Image.Format = "rw";
break;
case TrackSubchannelType.Raw:
case TrackSubchannelType.RawInterleaved:
xmlTrk.SubChannel.Image.format = "rw_raw";
xmlTrk.SubChannel.Image.Format = "rw_raw";
break;
case TrackSubchannelType.Q16:
case TrackSubchannelType.Q16Interleaved:
xmlTrk.SubChannel.Image.format = "q16";
xmlTrk.SubChannel.Image.Format = "q16";
break;
}
if(trk.FileOffset > 0)
{
xmlTrk.SubChannel.Image.offset = trk.SubchannelOffset;
xmlTrk.SubChannel.Image.offsetSpecified = true;
}
xmlTrk.SubChannel.Image.Offset = trk.SubchannelOffset;
var subChkWorker = new Checksum();
@@ -476,7 +463,7 @@ public sealed partial class Sidecar
if(sectors - doneSectors >= sectorsToRead)
{
errno = image.ReadSectorsTag(doneSectors, sectorsToRead, xmlTrk.Sequence.TrackNumber,
errno = image.ReadSectorsTag(doneSectors, sectorsToRead, xmlTrk.Sequence.Number,
SectorTagType.CdSectorSubchannel, out sector);
UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, (long)doneSectors,
@@ -494,9 +481,8 @@ public sealed partial class Sidecar
}
else
{
errno = image.ReadSectorsTag(doneSectors, (uint)(sectors - doneSectors),
xmlTrk.Sequence.TrackNumber, SectorTagType.CdSectorSubchannel,
out sector);
errno = image.ReadSectorsTag(doneSectors, (uint)(sectors - doneSectors), xmlTrk.Sequence.Number,
SectorTagType.CdSectorSubchannel, out sector);
UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, (long)doneSectors,
(long)(trk.EndSector - trk.StartSector + 1));
@@ -515,9 +501,7 @@ public sealed partial class Sidecar
subChkWorker.Update(sector);
}
List<ChecksumType> subChecksums = subChkWorker.End();
xmlTrk.SubChannel.Checksums = subChecksums.ToArray();
xmlTrk.SubChannel.Checksums = subChkWorker.End();
EndProgress2();
}
@@ -528,25 +512,23 @@ public sealed partial class Sidecar
List<Partition> trkPartitions =
partitions.Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector).ToList();
xmlTrk.FileSystemInformation = new PartitionType[1];
xmlTrk.FileSystemInformation = new List<CommonTypes.AaruMetadata.Partition>();
if(trkPartitions.Count > 0)
{
xmlTrk.FileSystemInformation = new PartitionType[trkPartitions.Count];
for(int i = 0; i < trkPartitions.Count; i++)
foreach(Partition partition in trkPartitions)
{
xmlTrk.FileSystemInformation[i] = new PartitionType
var metadataPartition = new CommonTypes.AaruMetadata.Partition
{
Description = trkPartitions[i].Description,
EndSector = trkPartitions[i].End,
Name = trkPartitions[i].Name,
Sequence = (uint)trkPartitions[i].Sequence,
StartSector = trkPartitions[i].Start,
Type = trkPartitions[i].Type
Description = partition.Description,
EndSector = partition.End,
Name = partition.Name,
Sequence = (uint)partition.Sequence,
StartSector = partition.Start,
Type = partition.Type
};
List<FileSystemType> lstFs = new();
List<FileSystem> lstFs = new();
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
@@ -558,14 +540,14 @@ public sealed partial class Sidecar
return;
}
if(!plugin.Identify(image, trkPartitions[i]))
if(!plugin.Identify(image, partition))
continue;
plugin.GetInformation(image, trkPartitions[i], out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
plugin.GetInformation(image, partition, out _, encoding);
lstFs.Add(plugin.Metadata);
Statistics.AddFilesystem(plugin.Metadata.Type);
dskType = plugin.XmlFsType.Type switch
dskType = plugin.Metadata.Type switch
{
"Opera" => MediaType.ThreeDO,
"PC Engine filesystem" => MediaType.SuperCDROM2,
@@ -582,26 +564,28 @@ public sealed partial class Sidecar
}
if(lstFs.Count > 0)
xmlTrk.FileSystemInformation[i].FileSystems = lstFs.ToArray();
metadataPartition.FileSystems = lstFs;
xmlTrk.FileSystemInformation.Add(metadataPartition);
}
}
else
{
xmlTrk.FileSystemInformation[0] = new PartitionType
var metadataPartition = new CommonTypes.AaruMetadata.Partition
{
EndSector = xmlTrk.EndSector,
StartSector = xmlTrk.StartSector
};
List<FileSystemType> lstFs = new();
List<FileSystem> lstFs = new();
var xmlPart = new Partition
{
Start = xmlTrk.StartSector,
Length = xmlTrk.EndSector - xmlTrk.StartSector + 1,
Type = xmlTrk.TrackType1.ToString(),
Type = xmlTrk.Type.ToString(),
Size = xmlTrk.Size,
Sequence = xmlTrk.Sequence.TrackNumber
Sequence = xmlTrk.Sequence.Number
};
foreach(IFilesystem plugin in plugins.PluginsList.Values)
@@ -618,10 +602,10 @@ public sealed partial class Sidecar
continue;
plugin.GetInformation(image, xmlPart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
lstFs.Add(plugin.Metadata);
Statistics.AddFilesystem(plugin.Metadata.Type);
dskType = plugin.XmlFsType.Type switch
dskType = plugin.Metadata.Type switch
{
"Opera" => MediaType.ThreeDO,
"PC Engine filesystem" => MediaType.SuperCDROM2,
@@ -638,7 +622,9 @@ public sealed partial class Sidecar
}
if(lstFs.Count > 0)
xmlTrk.FileSystemInformation[0].FileSystems = lstFs.ToArray();
metadataPartition.FileSystems = lstFs;
xmlTrk.FileSystemInformation.Add(metadataPartition);
}
errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcData);
@@ -652,7 +638,7 @@ public sealed partial class Sidecar
{
var trackFlags = (CdFlags)flagsData[0];
xmlTrk.Flags = new TrackFlagsType
xmlTrk.Flags = new TrackFlags
{
PreEmphasis = trackFlags.HasFlag(CdFlags.PreEmphasis),
CopyPermitted = trackFlags.HasFlag(CdFlags.CopyPermitted),
@@ -662,11 +648,11 @@ public sealed partial class Sidecar
}
if(trk.Indexes?.Count > 0)
xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key).Select(i => new TrackIndexType
xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key).Select(i => new TrackIndex
{
index = i.Key,
Index = i.Key,
Value = i.Value
}).ToArray();
}).ToList();
trksLst.Add(xmlTrk);
}
@@ -674,36 +660,37 @@ public sealed partial class Sidecar
EndProgress();
if(trksLst != null)
sidecar.OpticalDisc[0].Track = trksLst.ToArray();
sidecar.OpticalDiscs[0].Track = trksLst;
// All XGD3 all have the same number of blocks
if(dskType == MediaType.XGD2 &&
sidecar.OpticalDisc[0].Track.Length == 1)
sidecar.OpticalDiscs[0].Track.Count == 1)
{
ulong blocks = sidecar.OpticalDisc[0].Track[0].EndSector - sidecar.OpticalDisc[0].Track[0].StartSector + 1;
ulong blocks = sidecar.OpticalDiscs[0].Track[0].EndSector - sidecar.OpticalDiscs[0].Track[0].StartSector +
1;
if(blocks is 25063 or 4229664 or 4246304) // Wxripper unlock
dskType = MediaType.XGD3;
}
(string type, string subType) discType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
sidecar.OpticalDisc[0].DiscType = discType.type;
sidecar.OpticalDisc[0].DiscSubType = discType.subType;
sidecar.OpticalDiscs[0].DiscType = discType.type;
sidecar.OpticalDiscs[0].DiscSubType = discType.subType;
Statistics.AddMedia(dskType, false);
if(image.DumpHardware != null)
sidecar.OpticalDisc[0].DumpHardwareArray = image.DumpHardware.ToArray();
sidecar.OpticalDiscs[0].DumpHardware = image.DumpHardware;
else if(!string.IsNullOrEmpty(image.Info.DriveManufacturer) ||
!string.IsNullOrEmpty(image.Info.DriveModel) ||
!string.IsNullOrEmpty(image.Info.DriveFirmwareRevision) ||
!string.IsNullOrEmpty(image.Info.DriveSerialNumber))
sidecar.OpticalDisc[0].DumpHardwareArray = new[]
sidecar.OpticalDiscs[0].DumpHardware = new List<DumpHardware>
{
new DumpHardwareType
new()
{
Extents = new[]
Extents = new List<Extent>
{
new ExtentType
new()
{
Start = 0,
End = image.Info.Sectors
@@ -713,7 +700,7 @@ public sealed partial class Sidecar
Model = image.Info.DriveModel,
Firmware = image.Info.DriveFirmwareRevision,
Serial = image.Info.DriveSerialNumber,
Software = new SoftwareType
Software = new Software
{
Name = image.Info.Application,
Version = image.Info.ApplicationVersion

View File

@@ -35,27 +35,27 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Helpers;
using Schemas;
namespace Aaru.Core;
public sealed partial class Sidecar
{
readonly ChecksumType[] _emptyChecksums;
readonly Encoding _encoding;
readonly FileInfo _fi;
readonly Guid _filterId;
readonly IBaseImage _image;
readonly string _imagePath;
readonly Checksum _imgChkWorker;
readonly PluginBase _plugins;
bool _aborted;
FileStream _fs;
CICMMetadataType _sidecar;
readonly List<CommonTypes.AaruMetadata.Checksum> _emptyChecksums;
readonly Encoding _encoding;
readonly FileInfo _fi;
readonly Guid _filterId;
readonly IBaseImage _image;
readonly string _imagePath;
readonly Checksum _imgChkWorker;
readonly PluginBase _plugins;
bool _aborted;
FileStream _fs;
Metadata _sidecar;
/// <summary>Initializes a new instance of this class</summary>
public Sidecar()
@@ -66,7 +66,7 @@ public sealed partial class Sidecar
var emptyChkWorker = new Checksum();
emptyChkWorker.Update(Array.Empty<byte>());
_emptyChecksums = emptyChkWorker.End().ToArray();
_emptyChecksums = emptyChkWorker.End();
}
/// <param name="image">Image</param>
@@ -79,7 +79,7 @@ public sealed partial class Sidecar
_imagePath = imagePath;
_filterId = filterId;
_encoding = encoding;
_sidecar = image.CicmMetadata ?? new CICMMetadataType();
_sidecar = image.AaruMetadata ?? new Metadata();
_plugins = GetPluginBase.Instance;
_fi = new FileInfo(imagePath);
_fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
@@ -89,7 +89,7 @@ public sealed partial class Sidecar
/// <summary>Implements creating a metadata sidecar</summary>
/// <returns>The metadata sidecar</returns>
public CICMMetadataType Create()
public Metadata Create()
{
// For fast debugging, skip checksum
//goto skipImageChecksum;
@@ -127,19 +127,14 @@ public sealed partial class Sidecar
EndProgress();
_fs.Close();
List<ChecksumType> imgChecksums = _imgChkWorker.End();
_sidecar.OpticalDisc = null;
_sidecar.BlockMedia = null;
_sidecar.AudioMedia = null;
_sidecar.LinearMedia = null;
List<CommonTypes.AaruMetadata.Checksum> imgChecksums = _imgChkWorker.End();
if(_aborted)
return _sidecar;
switch(_image.Info.XmlMediaType)
switch(_image.Info.MetadataMediaType)
{
case XmlMediaType.OpticalDisc:
case MetadataMediaType.OpticalDisc:
if(_image is IOpticalMediaImage opticalImage)
OpticalDisc(opticalImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar,
_encoding);
@@ -152,7 +147,7 @@ public sealed partial class Sidecar
}
break;
case XmlMediaType.BlockMedia:
case MetadataMediaType.BlockMedia:
if(_image is IMediaImage blockImage)
BlockMedia(blockImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding);
else
@@ -164,7 +159,7 @@ public sealed partial class Sidecar
}
break;
case XmlMediaType.LinearMedia:
case MetadataMediaType.LinearMedia:
if(_image is IByteAddressableImage byteAddressableImage)
LinearMedia(byteAddressableImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar,
_encoding);
@@ -177,7 +172,7 @@ public sealed partial class Sidecar
}
break;
case XmlMediaType.AudioMedia:
case MetadataMediaType.AudioMedia:
AudioMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding);
break;