Rename dicformat entities.

This commit is contained in:
2020-02-27 22:15:42 +00:00
parent ce3428d56e
commit 85a622d60d
5 changed files with 11 additions and 9 deletions

View File

@@ -34,13 +34,15 @@ namespace Aaru.DiscImages
{
public partial class AaruFormat
{
/// <summary>Magic identidier = "DICMFMT".</summary>
/// <summary>Old magic identidier = "DICMFRMT".</summary>
const ulong DIC_MAGIC = 0x544D52464D434944;
/// <summary>Magic identidier = "AARUFRMT".</summary>
const ulong AARU_MAGIC = 0x544D524655524141;
/// <summary>
/// Image format version. A change in this number indicates an incompatible change to the format that
/// prevents older implementations from reading it correctly, if at all.
/// </summary>
const byte DICF_VERSION = 1;
const byte AARUFMT_VERSION = 1;
/// <summary>Maximum read cache size, 256MiB.</summary>
const uint MAX_CACHE_SIZE = 256 * 1024 * 1024;
/// <summary>Size in bytes of LZMA properties.</summary>

View File

@@ -49,7 +49,7 @@ namespace Aaru.DiscImages
imageStream.Read(structureBytes, 0, structureBytes.Length);
header = Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
return header.identifier == DIC_MAGIC && header.imageMajorVersion <= DICF_VERSION;
return (header.identifier == DIC_MAGIC || header.identifier == AARU_MAGIC) && header.imageMajorVersion <= AARUFMT_VERSION;
}
}
}

View File

@@ -76,7 +76,7 @@ namespace Aaru.DiscImages
("nocompress", typeof(bool),
"Don't compress user data blocks. Other blocks will still be compressed", (object)false)
};
public IEnumerable<string> KnownExtensions => new[] {".dicf"};
public IEnumerable<string> KnownExtensions => new[] {".dicf",".aaru",".aaruformat",".aaruf"};
public bool IsWriting { get; private set; }
public string ErrorMessage { get; private set; }
}

View File

@@ -71,7 +71,7 @@ namespace Aaru.DiscImages
imageStream.Read(structureBytes, 0, structureBytes.Length);
header = Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
if(header.imageMajorVersion > DICF_VERSION)
if(header.imageMajorVersion > AARUFMT_VERSION)
throw new FeatureUnsupportedImageException($"Image version {header.imageMajorVersion} not recognized.");
imageInfo.Application = header.application;

View File

@@ -236,14 +236,14 @@ namespace Aaru.DiscImages
imageStream.Read(structureBytes, 0, structureBytes.Length);
header = Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
if(header.identifier != DIC_MAGIC)
if(header.identifier != DIC_MAGIC && header.identifier != AARU_MAGIC &&)
{
ErrorMessage = "Cannot append to a non Aaru Format image";
return false;
}
if(header.imageMajorVersion > DICF_VERSION)
if(header.imageMajorVersion > AARUFMT_VERSION)
{
ErrorMessage = $"Cannot append to an unknown image version {header.imageMajorVersion}";
@@ -262,14 +262,14 @@ namespace Aaru.DiscImages
{
header = new DicHeader
{
identifier = DIC_MAGIC, mediaType = mediaType, creationTime = DateTime.UtcNow.ToFileTimeUtc()
identifier = AARU_MAGIC, mediaType = mediaType, creationTime = DateTime.UtcNow.ToFileTimeUtc()
};
imageStream.Write(new byte[Marshal.SizeOf<DicHeader>()], 0, Marshal.SizeOf<DicHeader>());
}
header.application = "Aaru";
header.imageMajorVersion = DICF_VERSION;
header.imageMajorVersion = AARUFMT_VERSION;
header.imageMinorVersion = 0;
header.applicationMajorVersion = (byte)typeof(AaruFormat).Assembly.GetName().Version.Major;
header.applicationMinorVersion = (byte)typeof(AaruFormat).Assembly.GetName().Version.Minor;