Files
Aaru/DiscImageChef.Filesystems/AppleDOS/Info.cs

97 lines
4.1 KiB
C#
Raw Normal View History

2017-05-19 20:28:49 +01:00
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// 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/>.
//
// ----------------------------------------------------------------------------
2020-01-03 17:51:30 +00:00
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System.Text;
using Claunia.Encoding;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Helpers;
2017-12-21 14:30:38 +00:00
using Schemas;
using Encoding = System.Text.Encoding;
namespace DiscImageChef.Filesystems.AppleDOS
{
public partial class AppleDOS
{
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
if(imagePlugin.Info.Sectors != 455 && imagePlugin.Info.Sectors != 560) return false;
if(partition.Start > 0 || imagePlugin.Info.SectorSize != 256) return false;
2018-06-20 22:22:21 +01:00
int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
byte[] vtocB = imagePlugin.ReadSector((ulong)(17 * spt));
vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocB);
2018-06-22 08:08:38 +01:00
return vtoc.catalogSector < spt && vtoc.maxTrackSectorPairsPerSector <= 122 &&
vtoc.sectorsPerTrack == spt && vtoc.bytesPerSector == 256;
}
2017-12-26 08:01:40 +00:00
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
2018-06-22 08:08:38 +01:00
Encoding encoding)
{
2018-06-22 08:08:38 +01:00
Encoding = encoding ?? new Apple2();
information = "";
StringBuilder sb = new StringBuilder();
2017-12-21 16:07:20 +00:00
int spt;
spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
byte[] vtocB = imagePlugin.ReadSector((ulong)(17 * spt));
vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocB);
sb.AppendLine("Apple DOS File System");
sb.AppendLine();
2017-12-19 20:33:03 +00:00
sb.AppendFormat("Catalog starts at sector {0} of track {1}", vtoc.catalogSector, vtoc.catalogTrack)
.AppendLine();
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();
2017-12-19 20:33:03 +00:00
sb.AppendFormat("Track allocation is {0}", vtoc.allocationDirection > 0 ? "forward" : "reverse")
.AppendLine();
information = sb.ToString();
2017-12-26 08:01:40 +00:00
XmlFsType = new FileSystemType
{
2018-06-22 08:08:38 +01:00
Bootable = true,
2019-04-23 01:38:33 +01:00
Clusters = imagePlugin.Info.Sectors,
ClusterSize = imagePlugin.Info.SectorSize,
2018-06-22 08:08:38 +01:00
Type = "Apple DOS"
};
}
}
2017-12-19 20:33:03 +00:00
}