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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Filename : CBM.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Component : Commodore file system plugin.
|
2016-07-28 18:13:49 +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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
|
// Copyright © 2011-2025 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;
|
2024-04-22 04:49:14 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
|
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2024-04-22 04:49:14 +01:00
|
|
|
|
using Aaru.CommonTypes.Structs;
|
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 />
|
2022-12-07 13:07:31 +00:00
|
|
|
|
/// <summary>Implements detection of the filesystem used in 8-bit Commodore microcomputers</summary>
|
2024-04-22 04:49:14 +01:00
|
|
|
|
public sealed partial class CBM : IReadOnlyFilesystem
|
2011-03-03 18:34:33 +00:00
|
|
|
|
{
|
2024-04-22 04:49:14 +01:00
|
|
|
|
byte[] _bam;
|
|
|
|
|
|
Dictionary<string, CachedFile> _cache;
|
|
|
|
|
|
bool _debug;
|
|
|
|
|
|
byte[] _diskHeader;
|
2024-04-22 15:38:31 +01:00
|
|
|
|
bool _is1581;
|
2024-04-22 04:49:14 +01:00
|
|
|
|
bool _mounted;
|
|
|
|
|
|
byte[] _root;
|
|
|
|
|
|
FileSystemInfo _statfs;
|
|
|
|
|
|
|
|
|
|
|
|
#region IReadOnlyFilesystem Members
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public string Name => Localization.CBM_Name;
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public Guid Id => new("D104744E-A376-450C-BAC0-1347C93F983B");
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-11-28 02:59:53 +00:00
|
|
|
|
public string Author => Authors.NataliaPortillo;
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
2024-04-22 04:49:14 +01:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public ErrorNumber ListXAttr(string path, out List<string> xattrs)
|
|
|
|
|
|
{
|
|
|
|
|
|
xattrs = null;
|
|
|
|
|
|
|
|
|
|
|
|
return ErrorNumber.NotSupported;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) => ErrorNumber.NotSupported;
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public ErrorNumber ReadLink(string path, out string dest)
|
|
|
|
|
|
{
|
|
|
|
|
|
dest = null;
|
|
|
|
|
|
|
|
|
|
|
|
return ErrorNumber.NotSupported;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public FileSystem Metadata { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
|
|
|
|
|
Array.Empty<(string name, Type type, string description)>();
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public Dictionary<string, string> Namespaces => null;
|
|
|
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
|
#endregion
|
2024-04-22 04:49:14 +01:00
|
|
|
|
|
|
|
|
|
|
static Dictionary<string, string> GetDefaultOptions() => new()
|
|
|
|
|
|
{
|
|
|
|
|
|
{
|
|
|
|
|
|
"debug", false.ToString()
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2024-04-22 15:38:31 +01:00
|
|
|
|
|
|
|
|
|
|
ulong CbmChsToLba(byte track, byte sector, bool is1581)
|
|
|
|
|
|
{
|
2024-05-01 17:46:53 +01:00
|
|
|
|
if(track is 0 or > 40) return 0;
|
2024-04-22 15:38:31 +01:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(is1581) return (ulong)((track - 1) * 40 + sector - 1);
|
2024-04-22 15:38:31 +01:00
|
|
|
|
|
|
|
|
|
|
return trackStartingLbas[track - 1] + sector;
|
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
}
|