Files
Aaru/Aaru.Filesystems/ECMA67/Info.cs

100 lines
3.6 KiB
C#
Raw Normal View History

// /***************************************************************************
2020-02-27 12:31:25 +00:00
// Aaru Data Preservation Suite
2016-09-17 16:56:09 +01:00
// ----------------------------------------------------------------------------
//
2022-12-07 13:07:31 +00:00
// Filename : Info.cs
2016-09-17 16:56:09 +01:00
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : ECMA-67 plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Identifies the ECMA-67 file system and shows information.
//
// --[ 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
2016-09-17 16:56:09 +01:00
// ****************************************************************************/
using System.Linq;
using System.Text;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes.Interfaces;
2022-12-07 13:07:31 +00:00
using Aaru.Helpers;
using Partition = Aaru.CommonTypes.Partition;
2016-09-17 16:56:09 +01:00
namespace Aaru.Filesystems;
2022-03-06 13:29:38 +00:00
/// <inheritdoc />
/// <summary>Implements detection of the filesystem described in ECMA-67</summary>
2022-12-07 13:07:31 +00:00
public sealed partial class ECMA67
2016-09-17 16:56:09 +01:00
{
#region IFilesystem Members
2022-03-06 13:29:38 +00:00
/// <inheritdoc />
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
2024-05-01 04:05:22 +01:00
if(partition.Start > 0) return false;
2024-05-01 04:05:22 +01:00
if(partition.End < 8) return false;
2016-09-17 16:56:09 +01:00
ErrorNumber errno = imagePlugin.ReadSector(6, false, out byte[] sector, out _);
2016-09-17 16:56:09 +01:00
2024-05-01 04:05:22 +01:00
if(errno != ErrorNumber.NoError) return false;
2016-09-17 16:56:09 +01:00
2024-05-01 04:05:22 +01:00
if(sector.Length != 128) return false;
2016-09-17 16:56:09 +01:00
2022-03-06 13:29:38 +00:00
VolumeLabel vol = Marshal.ByteArrayToStructureLittleEndian<VolumeLabel>(sector);
return _magic.SequenceEqual(vol.labelIdentifier) && vol is { labelNumber: 1, recordLength: 0x31 };
2022-03-06 13:29:38 +00:00
}
2016-09-17 16:56:09 +01:00
2022-03-06 13:29:38 +00:00
/// <inheritdoc />
public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information,
out FileSystem metadata)
2022-03-06 13:29:38 +00:00
{
information = "";
metadata = new FileSystem();
ErrorNumber errno = imagePlugin.ReadSector(6, false, out byte[] sector, out _);
2016-09-17 16:56:09 +01:00
2024-05-01 04:05:22 +01:00
if(errno != ErrorNumber.NoError) return;
2016-09-17 16:56:09 +01:00
2022-03-06 13:29:38 +00:00
var sbInformation = new StringBuilder();
2016-09-17 16:56:09 +01:00
2022-03-06 13:29:38 +00:00
VolumeLabel vol = Marshal.ByteArrayToStructureLittleEndian<VolumeLabel>(sector);
2016-09-17 16:56:09 +01:00
sbInformation.AppendLine(Localization.ECMA_67);
2016-09-17 16:56:09 +01:00
2024-05-01 04:05:22 +01:00
sbInformation.AppendFormat(Localization.Volume_name_0, Encoding.ASCII.GetString(vol.volumeIdentifier))
.AppendLine();
sbInformation.AppendFormat(Localization.Volume_owner_0, Encoding.ASCII.GetString(vol.owner)).AppendLine();
2016-09-17 16:56:09 +01:00
metadata = new FileSystem
{
Type = FS_TYPE,
2022-03-06 13:29:38 +00:00
ClusterSize = 256,
Clusters = partition.End - partition.Start + 1,
VolumeName = Encoding.ASCII.GetString(vol.volumeIdentifier)
};
information = sbInformation.ToString();
}
#endregion
2016-09-17 16:56:09 +01:00
}