diff --git a/Aaru.Core/Sidecar/AudioMedia.cs b/Aaru.Core/Sidecar/AudioMedia.cs
index c6f6dacec..3b15e4f81 100644
--- a/Aaru.Core/Sidecar/AudioMedia.cs
+++ b/Aaru.Core/Sidecar/AudioMedia.cs
@@ -52,7 +52,7 @@ namespace Aaru.Core
/// List of image checksums
/// Metadata sidecar
/// Encoding to be used for filesystem plugins
- static void AudioMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
+ static void AudioMedia(IBaseImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
{
sidecar.AudioMedia = new[]
diff --git a/Aaru.Core/Sidecar/LinearMedia.cs b/Aaru.Core/Sidecar/LinearMedia.cs
index ca84cefb4..2a1489e1a 100644
--- a/Aaru.Core/Sidecar/LinearMedia.cs
+++ b/Aaru.Core/Sidecar/LinearMedia.cs
@@ -38,36 +38,35 @@ using Aaru.CommonTypes;
using Aaru.CommonTypes.Interfaces;
using Schemas;
-namespace Aaru.Core
+namespace Aaru.Core;
+
+public sealed partial class Sidecar
{
- public sealed partial class Sidecar
+ // TODO: Complete it
+ /// Creates a metadata sidecar for linear media (e.g. ROM chip)
+ /// Image
+ /// Filter uuid
+ /// Image path
+ /// Image file information
+ /// Image plugins
+ /// List of image checksums
+ /// Metadata sidecar
+ /// Encoding to be used for filesystem plugins
+ static void LinearMedia(IByteAddressableImage image, Guid filterId, string imagePath, FileInfo fi,
+ PluginBase plugins, List imgChecksums, ref CICMMetadataType sidecar,
+ Encoding encoding) => sidecar.LinearMedia = new[]
{
- // TODO: Complete it
- /// Creates a metadata sidecar for linear media (e.g. ROM chip)
- /// Image
- /// Filter uuid
- /// Image path
- /// Image file information
- /// Image plugins
- /// List of image checksums
- /// Metadata sidecar
- /// Encoding to be used for filesystem plugins
- void LinearMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
- List imgChecksums, ref CICMMetadataType sidecar, Encoding encoding) =>
- sidecar.LinearMedia = new[]
+ new LinearMediaType
+ {
+ Checksums = imgChecksums.ToArray(),
+ Image = new ImageType
{
- new LinearMediaType
- {
- Checksums = imgChecksums.ToArray(),
- Image = new ImageType
- {
- format = image.Format,
- offset = 0,
- offsetSpecified = true,
- Value = Path.GetFileName(imagePath)
- },
- Size = (ulong)fi.Length
- }
- };
- }
+ format = image.Format,
+ offset = 0,
+ offsetSpecified = true,
+ Value = Path.GetFileName(imagePath)
+ },
+ Size = image.Info.Sectors
+ }
+ };
}
\ No newline at end of file
diff --git a/Aaru.Core/Sidecar/Sidecar.cs b/Aaru.Core/Sidecar/Sidecar.cs
index 333676e5a..0062da584 100644
--- a/Aaru.Core/Sidecar/Sidecar.cs
+++ b/Aaru.Core/Sidecar/Sidecar.cs
@@ -40,139 +40,155 @@ using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Schemas;
-namespace Aaru.Core
+namespace Aaru.Core;
+
+public sealed partial class Sidecar
{
- 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;
+
+ /// Initializes a new instance of this class
+ public Sidecar()
{
- readonly ChecksumType[] _emptyChecksums;
- readonly Encoding _encoding;
- readonly FileInfo _fi;
- readonly Guid _filterId;
- readonly IMediaImage _image;
- readonly string _imagePath;
- readonly Checksum _imgChkWorker;
- readonly PluginBase _plugins;
- bool _aborted;
- FileStream _fs;
- CICMMetadataType _sidecar;
+ _plugins = GetPluginBase.Instance;
+ _imgChkWorker = new Checksum();
+ _aborted = false;
- /// Initializes a new instance of this class
- public Sidecar()
+ var emptyChkWorker = new Checksum();
+ emptyChkWorker.Update(Array.Empty());
+ _emptyChecksums = emptyChkWorker.End().ToArray();
+ }
+
+ /// Image
+ /// Path to image
+ /// Filter uuid
+ /// Encoding for analysis
+ public Sidecar(IBaseImage image, string imagePath, Guid filterId, Encoding encoding)
+ {
+ _image = image;
+ _imagePath = imagePath;
+ _filterId = filterId;
+ _encoding = encoding;
+ _sidecar = image.CicmMetadata ?? new CICMMetadataType();
+ _plugins = GetPluginBase.Instance;
+ _fi = new FileInfo(imagePath);
+ _fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
+ _imgChkWorker = new Checksum();
+ _aborted = false;
+ }
+
+ /// Implements creating a metadata sidecar
+ /// The metadata sidecar
+ public CICMMetadataType Create()
+ {
+ // For fast debugging, skip checksum
+ //goto skipImageChecksum;
+
+ byte[] data;
+ long position = 0;
+ UpdateStatus("Hashing image file...");
+ InitProgress();
+
+ while(position < _fi.Length - 1048576)
{
- _plugins = GetPluginBase.Instance;
- _imgChkWorker = new Checksum();
- _aborted = false;
+ if(_aborted)
+ return _sidecar;
- var emptyChkWorker = new Checksum();
- emptyChkWorker.Update(Array.Empty());
- _emptyChecksums = emptyChkWorker.End().ToArray();
- }
-
- /// Image
- /// Path to image
- /// Filter uuid
- /// Encoding for analysis
- public Sidecar(IMediaImage image, string imagePath, Guid filterId, Encoding encoding)
- {
- _image = image;
- _imagePath = imagePath;
- _filterId = filterId;
- _encoding = encoding;
- _sidecar = image.CicmMetadata ?? new CICMMetadataType();
- _plugins = GetPluginBase.Instance;
- _fi = new FileInfo(imagePath);
- _fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
- _imgChkWorker = new Checksum();
- _aborted = false;
- }
-
- /// Implements creating a metadata sidecar
- /// The metadata sidecar
- public CICMMetadataType Create()
- {
- // For fast debugging, skip checksum
- //goto skipImageChecksum;
-
- byte[] data;
- long position = 0;
- UpdateStatus("Hashing image file...");
- InitProgress();
-
- while(position < _fi.Length - 1048576)
- {
- if(_aborted)
- return _sidecar;
-
- data = new byte[1048576];
- _fs.Read(data, 0, 1048576);
-
- UpdateProgress("Hashing image file byte {0} of {1}", position, _fi.Length);
-
- _imgChkWorker.Update(data);
-
- position += 1048576;
- }
-
- data = new byte[_fi.Length - position];
- _fs.Read(data, 0, (int)(_fi.Length - position));
+ data = new byte[1048576];
+ _fs.Read(data, 0, 1048576);
UpdateProgress("Hashing image file byte {0} of {1}", position, _fi.Length);
_imgChkWorker.Update(data);
- // For fast debugging, skip checksum
- //skipImageChecksum:
+ position += 1048576;
+ }
- EndProgress();
- _fs.Close();
+ data = new byte[_fi.Length - position];
+ _fs.Read(data, 0, (int)(_fi.Length - position));
- List imgChecksums = _imgChkWorker.End();
+ UpdateProgress("Hashing image file byte {0} of {1}", position, _fi.Length);
- _sidecar.OpticalDisc = null;
- _sidecar.BlockMedia = null;
- _sidecar.AudioMedia = null;
- _sidecar.LinearMedia = null;
+ _imgChkWorker.Update(data);
- if(_aborted)
- return _sidecar;
+ // For fast debugging, skip checksum
+ //skipImageChecksum:
- switch(_image.Info.XmlMediaType)
- {
- case XmlMediaType.OpticalDisc:
- if(_image is IOpticalMediaImage opticalImage)
- OpticalDisc(opticalImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar,
- _encoding);
- else
- {
- AaruConsole.
- ErrorWriteLine("The specified image says it contains an optical media but at the same time says it does not support them.");
+ EndProgress();
+ _fs.Close();
- AaruConsole.ErrorWriteLine("Please open an issue at Github.");
- }
+ List imgChecksums = _imgChkWorker.End();
- break;
- case XmlMediaType.BlockMedia:
- BlockMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding);
-
- break;
- case XmlMediaType.LinearMedia:
- LinearMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding);
-
- break;
- case XmlMediaType.AudioMedia:
- AudioMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding);
-
- break;
- }
+ _sidecar.OpticalDisc = null;
+ _sidecar.BlockMedia = null;
+ _sidecar.AudioMedia = null;
+ _sidecar.LinearMedia = null;
+ if(_aborted)
return _sidecar;
+
+ switch(_image.Info.XmlMediaType)
+ {
+ case XmlMediaType.OpticalDisc:
+ if(_image is IOpticalMediaImage opticalImage)
+ OpticalDisc(opticalImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar,
+ _encoding);
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine("The specified image says it contains an optical media but at the same time says it does not support them.");
+
+ AaruConsole.ErrorWriteLine("Please open an issue at Github.");
+ }
+
+ break;
+ case XmlMediaType.BlockMedia:
+ if(_image is IMediaImage blockImage)
+ BlockMedia(blockImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding);
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine("The specified image says it contains a block addressable media but at the same time says it does not support them.");
+
+ AaruConsole.ErrorWriteLine("Please open an issue at Github.");
+ }
+
+ break;
+ case XmlMediaType.LinearMedia:
+ if(_image is IByteAddressableImage byteAddressableImage)
+ LinearMedia(byteAddressableImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar,
+ _encoding);
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine("The specified image says it contains a byte addressable media but at the same time says it does not support them.");
+
+ AaruConsole.ErrorWriteLine("Please open an issue at Github.");
+ }
+
+ break;
+ case XmlMediaType.AudioMedia:
+ AudioMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding);
+
+ break;
}
- /// Aborts sidecar running operation
- public void Abort()
- {
- UpdateStatus("Aborting...");
- _aborted = true;
- }
+ return _sidecar;
+ }
+
+ /// Aborts sidecar running operation
+ public void Abort()
+ {
+ UpdateStatus("Aborting...");
+ _aborted = true;
}
}
\ No newline at end of file
diff --git a/Aaru/Commands/Image/CreateSidecar.cs b/Aaru/Commands/Image/CreateSidecar.cs
index 709aaf3d9..ce8c571dc 100644
--- a/Aaru/Commands/Image/CreateSidecar.cs
+++ b/Aaru/Commands/Image/CreateSidecar.cs
@@ -178,7 +178,7 @@ namespace Aaru.Commands.Image
try
{
- IMediaImage imageFormat = null;
+ IBaseImage imageFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
{