Files
Aaru/Aaru.Images/DiskCopy42/Verify.cs

76 lines
3.1 KiB
C#
Raw Permalink Normal View History

// /***************************************************************************
2020-02-27 12:31:25 +00:00
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Verify.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Verifies Apple DiskCopy 4.2 disk images.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2024-12-19 10:45:18 +00:00
// Copyright © 2011-2025 Natalia Portillo
// ****************************************************************************/
using System.IO;
using Aaru.Helpers;
using Aaru.Logging;
namespace Aaru.Images;
2022-03-06 13:29:38 +00:00
public sealed partial class DiskCopy42
{
2023-10-03 23:34:59 +01:00
#region IVerifiableImage Members
2022-03-06 13:29:38 +00:00
/// <inheritdoc />
public bool? VerifyMediaImage()
{
var data = new byte[header.DataSize];
var tags = new byte[header.TagSize];
uint tagsChk = 0;
2025-08-17 06:11:22 +01:00
AaruLogging.Debug(MODULE_NAME, Localization.Reading_data);
2022-03-06 13:29:38 +00:00
Stream dataStream = dc42ImageFilter.GetDataForkStream();
dataStream.Seek(dataOffset, SeekOrigin.Begin);
dataStream.EnsureRead(data, 0, (int)header.DataSize);
2025-08-17 06:11:22 +01:00
AaruLogging.Debug(MODULE_NAME, Localization.Calculating_data_checksum);
2022-03-06 13:29:38 +00:00
uint dataChk = CheckSum(data);
2025-08-17 06:11:22 +01:00
AaruLogging.Debug(MODULE_NAME, Localization.Calculated_data_checksum_equals_0_X8, dataChk);
AaruLogging.Debug(MODULE_NAME, Localization.Stored_data_checksum_equals_0_X8, header.DataChecksum);
2024-05-01 04:05:22 +01:00
if(header.TagSize <= 0) return dataChk == header.DataChecksum && tagsChk == header.TagChecksum;
2025-08-17 06:11:22 +01:00
AaruLogging.Debug(MODULE_NAME, Localization.Reading_tags);
2022-03-06 13:29:38 +00:00
Stream tagStream = dc42ImageFilter.GetDataForkStream();
tagStream.Seek(tagOffset, SeekOrigin.Begin);
tagStream.EnsureRead(tags, 0, (int)header.TagSize);
2025-08-17 06:11:22 +01:00
AaruLogging.Debug(MODULE_NAME, Localization.Calculating_tag_checksum);
2022-03-06 13:29:38 +00:00
tagsChk = CheckSum(tags);
2025-08-17 06:11:22 +01:00
AaruLogging.Debug(MODULE_NAME, Localization.Calculated_tag_checksum_equals_0_X8, tagsChk);
AaruLogging.Debug(MODULE_NAME, Localization.Stored_tag_checksum_equals_0_X8, header.TagChecksum);
2022-03-06 13:29:38 +00:00
return dataChk == header.DataChecksum && tagsChk == header.TagChecksum;
}
2023-10-03 23:34:59 +01:00
#endregion
}