2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2016-08-26 01:43:15 +01:00
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : CPM.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2016-08-26 01:45:58 +01:00
|
|
|
|
// Component : CP/M filesystem plugin.
|
2016-08-26 01:43:15 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2016-08-26 01:45:58 +01:00
|
|
|
|
// Constructors and common variables for the CP/M filesystem plugin.
|
2016-08-26 01:43:15 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2018-12-29 17:34:38 +00:00
|
|
|
|
// Copyright © 2011-2019 Natalia Portillo
|
2016-08-26 01:43:15 +01:00
|
|
|
|
// ****************************************************************************/
|
2016-08-26 01:45:58 +01:00
|
|
|
|
|
2016-08-26 01:43:15 +01:00
|
|
|
|
using System;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
using System.Collections.Generic;
|
2017-06-06 21:23:20 +01:00
|
|
|
|
using System.Text;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using DiscImageChef.CommonTypes;
|
2018-06-25 19:08:16 +01:00
|
|
|
|
using DiscImageChef.CommonTypes.Interfaces;
|
|
|
|
|
|
using DiscImageChef.CommonTypes.Structs;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
using Schemas;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
|
2016-08-26 01:43:15 +01:00
|
|
|
|
namespace DiscImageChef.Filesystems.CPM
|
|
|
|
|
|
{
|
2017-12-26 07:23:09 +00:00
|
|
|
|
partial class CPM : IReadOnlyFilesystem
|
2016-08-26 01:43:15 +01:00
|
|
|
|
{
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// True if <see cref="Identify" /> thinks this is a CP/M filesystem
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
bool cpmFound;
|
|
|
|
|
|
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Cached <see cref="FileSystemInfo" />
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
FileSystemInfo cpmStat;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Cached file passwords, decoded
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
Dictionary<string, byte[]> decodedPasswordCache;
|
|
|
|
|
|
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Stores all known CP/M disk definitions
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
CpmDefinitions definitions;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
IMediaImage device;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Cached directory listing
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
List<string> dirList;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// CP/M disc parameter block (on-memory)
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
DiscParameterBlock dpb;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Cached file data
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
Dictionary<string, byte[]> fileCache;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// The volume label, if the CP/M filesystem contains one
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
string label;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Timestamp in volume label for creation
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
byte[] labelCreationDate;
|
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Timestamp in volume label for update
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
byte[] labelUpdateDate;
|
2017-12-27 23:55:59 +00:00
|
|
|
|
bool mounted;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
Partition partition;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Cached file passwords
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
Dictionary<string, byte[]> passwordCache;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Sector deinterleaving mask
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
int[] sectorMask;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// True if there are CP/M 3 timestamps
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
bool standardTimestamps;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// Cached file <see cref="FileEntryInfo" />
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
Dictionary<string, FileEntryInfo> statCache;
|
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// True if there are timestamps in Z80DOS or DOS+ format
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
bool thirdPartyTimestamps;
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// If <see cref="Identify" /> thinks this is a CP/M filesystem, this is the definition for it
|
2016-08-26 01:45:58 +01:00
|
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
CpmDefinition workingDefinition;
|
2019-04-17 00:11:28 +01:00
|
|
|
|
IReadOnlyFilesystem readOnlyFilesystemImplementation;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
|
|
|
|
|
|
public FileSystemType XmlFsType { get; private set; }
|
2017-12-27 23:55:59 +00:00
|
|
|
|
public Encoding Encoding { get; private set; }
|
|
|
|
|
|
public string Name => "CP/M File System";
|
|
|
|
|
|
public Guid Id => new Guid("AA2B8585-41DF-4E3B-8A35-D1A935E2F8A1");
|
2018-08-29 22:15:43 +01:00
|
|
|
|
public string Author => "Natalia Portillo";
|
2017-12-27 23:55:59 +00:00
|
|
|
|
|
2017-12-28 18:08:15 +00:00
|
|
|
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
new (string name, Type type, string description)[] { };
|
2017-12-28 00:29:04 +00:00
|
|
|
|
|
2019-04-17 00:11:28 +01:00
|
|
|
|
public Dictionary<string, string> Namespaces => null;
|
|
|
|
|
|
|
2018-08-29 22:15:43 +01:00
|
|
|
|
static Dictionary<string, string> GetDefaultOptions() =>
|
|
|
|
|
|
new Dictionary<string, string> {{"debug", false.ToString()}};
|
2016-08-26 01:43:15 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|