Files
Aaru/Aaru.Filesystems/AppleDOS/Structs.cs

117 lines
4.3 KiB
C#
Raw Normal View History

2017-05-19 20:28:49 +01:00
// /***************************************************************************
2020-02-27 12:31:25 +00:00
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Structs.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Apple DOS filesystem plugin.
//
// --[ 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-12-03 16:07:10 +00:00
// Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/
2022-03-07 07:36:44 +00:00
using System.Runtime.InteropServices;
using Aaru.CommonTypes.Interfaces;
2022-03-07 07:36:44 +00:00
namespace Aaru.Filesystems;
2022-03-06 13:29:38 +00:00
public sealed partial class AppleDOS
{
2022-03-06 13:29:38 +00:00
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct Vtoc
{
2022-03-06 13:29:38 +00:00
public readonly byte unused1;
public readonly byte catalogTrack;
public readonly byte catalogSector;
public readonly byte dosRelease;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public readonly byte[] unused2;
public readonly byte volumeNumber;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] unused3;
public readonly byte maxTrackSectorPairsPerSector;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] unused4;
public readonly byte lastAllocatedSector;
public readonly sbyte allocationDirection;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public readonly byte[] unused5;
public readonly byte tracks;
public readonly byte sectorsPerTrack;
public readonly ushort bytesPerSector;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 200)]
public readonly byte[] bitmap;
}
2022-03-06 13:29:38 +00:00
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct CatalogSector
{
public readonly byte unused1;
public readonly byte trackOfNext;
public readonly byte sectorOfNext;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] unused2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
public readonly FileEntry[] entries;
}
2022-03-06 13:29:38 +00:00
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct FileEntry
{
public readonly byte extentTrack;
public readonly byte extentSector;
public readonly byte typeAndFlags;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
public readonly byte[] filename;
public readonly ushort length;
}
2022-03-06 13:29:38 +00:00
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct TrackSectorList
{
public readonly byte unused1;
public readonly byte nextListTrack;
public readonly byte nextListSector;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public readonly byte[] unused2;
public readonly ushort sectorOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] unused3;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 122)]
public readonly TrackSectorListEntry[] entries;
}
2022-03-06 13:29:38 +00:00
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct TrackSectorListEntry
{
public readonly byte track;
public readonly byte sector;
}
sealed class AppleDosFileNode : IFileNode
{
internal byte[] _cache;
/// <inheritdoc />
public string Path { get; init; }
/// <inheritdoc />
public long Length { get; init; }
/// <inheritdoc />
public long Offset { get; set; }
}
2017-12-19 20:33:03 +00:00
}