2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2016-10-07 00:41:59 +01:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Info.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : Apple DOS filesystem plugin.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Identifies the Apple DOS 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-10-07 00:41:59 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
2016-10-07 00:41:59 +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;
|
|
|
|
|
using Aaru.Helpers;
|
2020-02-29 18:03:35 +00:00
|
|
|
using Claunia.Encoding;
|
2017-12-21 14:30:38 +00:00
|
|
|
using Schemas;
|
2017-12-26 06:05:12 +00:00
|
|
|
using Encoding = System.Text.Encoding;
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public sealed partial class AppleDOS
|
2016-10-07 00:41:59 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2016-10-07 00:41:59 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if(imagePlugin.Info.Sectors != 455 &&
|
|
|
|
|
imagePlugin.Info.Sectors != 560)
|
|
|
|
|
return false;
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(partition.Start > 0 ||
|
|
|
|
|
imagePlugin.Info.SectorSize != 256)
|
|
|
|
|
return false;
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB);
|
2021-09-19 21:16:47 +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
|
|
|
_vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocB);
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
return _vtoc.catalogSector < spt && _vtoc.maxTrackSectorPairsPerSector <= 122 && _vtoc.sectorsPerTrack == spt &&
|
|
|
|
|
_vtoc.bytesPerSector == 256;
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2016-10-07 00:41:59 +01: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 ?? new Apple2();
|
|
|
|
|
information = "";
|
|
|
|
|
var sb = new StringBuilder();
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB);
|
2021-09-19 21:16:47 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
return;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
_vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocB);
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sb.AppendLine("Apple DOS File System");
|
|
|
|
|
sb.AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sb.AppendFormat("Catalog starts at sector {0} of track {1}", _vtoc.catalogSector, _vtoc.catalogTrack).
|
|
|
|
|
AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
sb.AppendFormat("File system initialized by DOS release {0}", _vtoc.dosRelease).AppendLine();
|
|
|
|
|
sb.AppendFormat("Disk volume number {0}", _vtoc.volumeNumber).AppendLine();
|
|
|
|
|
sb.AppendFormat("Sectors allocated at most in track {0}", _vtoc.lastAllocatedSector).AppendLine();
|
|
|
|
|
sb.AppendFormat("{0} tracks in volume", _vtoc.tracks).AppendLine();
|
|
|
|
|
sb.AppendFormat("{0} sectors per track", _vtoc.sectorsPerTrack).AppendLine();
|
|
|
|
|
sb.AppendFormat("{0} bytes per sector", _vtoc.bytesPerSector).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
sb.AppendFormat("Track allocation is {0}", _vtoc.allocationDirection > 0 ? "forward" : "reverse").AppendLine();
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
information = sb.ToString();
|
2016-10-07 00:41:59 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
XmlFsType = new FileSystemType
|
|
|
|
|
{
|
|
|
|
|
Bootable = true,
|
|
|
|
|
Clusters = imagePlugin.Info.Sectors,
|
|
|
|
|
ClusterSize = imagePlugin.Info.SectorSize,
|
|
|
|
|
Type = "Apple DOS"
|
|
|
|
|
};
|
2016-10-07 00:41:59 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|