2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : PCEngine.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : NEC PC-Engine CD filesystem plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the NEC PC-Engine CD filesystem 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:53 +00:00
|
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ****************************************************************************/
|
2014-04-17 19:58:14 +00:00
|
|
|
|
|
2011-03-03 18:34:33 +00:00
|
|
|
|
using System;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Schemas;
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of the PC-Engine CD file headers</summary>
|
|
|
|
|
|
public sealed class PCEnginePlugin : IFilesystem
|
2011-03-03 18:34:33 +00:00
|
|
|
|
{
|
2021-08-17 14:25:12 +01:00
|
|
|
|
/// <inheritdoc />
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public FileSystemType XmlFsType { get; private set; }
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public Encoding Encoding { get; private set; }
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public string Name => "PC Engine CD Plugin";
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public Guid Id => new("e5ee6d7c-90fa-49bd-ac89-14ef750b8af3");
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public string Author => "Natalia Portillo";
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(2 + partition.Start >= partition.End)
|
|
|
|
|
|
return false;
|
2016-07-27 13:32:45 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
byte[] systemDescriptor = new byte[23];
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] sector);
|
2014-07-09 19:49:14 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return false;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Array.Copy(sector, 0x20, systemDescriptor, 0, 23);
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return Encoding.ASCII.GetString(systemDescriptor) == "PC Engine CD-ROM SYSTEM";
|
|
|
|
|
|
}
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-03-07 07:36:44 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Encoding = encoding ?? Encoding.GetEncoding("shift_jis");
|
|
|
|
|
|
information = "";
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Type = "PC Engine filesystem",
|
|
|
|
|
|
Clusters = (partition.End - partition.Start + 1) / imagePlugin.Info.SectorSize * 2048,
|
|
|
|
|
|
ClusterSize = 2048
|
|
|
|
|
|
};
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
}
|