REFACTOR: Final cleanup of DiscImageChef.Filesystems.

This commit is contained in:
2017-12-24 02:37:41 +00:00
parent ec73a6cdc3
commit 4115698ac8
94 changed files with 5196 additions and 5116 deletions

View File

@@ -37,496 +37,499 @@ namespace DiscImageChef.Filesystems.CPM
partial class CPM
{
/// <summary>
/// Most of the times this structure is hard wired or generated by CP/M, not stored on disk
/// Most of the times this structure is hard wired or generated by CP/M, not stored on disk
/// </summary>
class DiscParameterBlock
{
/// <summary>
/// Sectors per track
/// </summary>
public ushort spt;
/// <summary>
/// Block shift
/// </summary>
public byte bsh;
/// <summary>
/// Block mask
/// </summary>
public byte blm;
/// <summary>
/// Extent mask
/// </summary>
public byte exm;
/// <summary>
/// Blocks on disk - 1
/// </summary>
public ushort dsm;
/// <summary>
/// Directory entries - 1
/// </summary>
public ushort drm;
/// <summary>
/// First byte of allocation bitmap
/// First byte of allocation bitmap
/// </summary>
public byte al0;
/// <summary>
/// Second byte of allocation bitmap
/// Second byte of allocation bitmap
/// </summary>
public byte al1;
/// <summary>
/// Checksum vector size
/// Block mask
/// </summary>
public byte blm;
/// <summary>
/// Block shift
/// </summary>
public byte bsh;
/// <summary>
/// Checksum vector size
/// </summary>
public ushort cks;
/// <summary>
/// Reserved tracks
/// Directory entries - 1
/// </summary>
public ushort drm;
/// <summary>
/// Blocks on disk - 1
/// </summary>
public ushort dsm;
/// <summary>
/// Extent mask
/// </summary>
public byte exm;
/// <summary>
/// Reserved tracks
/// </summary>
public ushort off;
/// <summary>
/// Physical sector shift
/// Physical sector mask
/// </summary>
public byte phm;
/// <summary>
/// Physical sector shift
/// </summary>
public byte psh;
/// <summary>
/// Physical sector mask
/// Sectors per track
/// </summary>
public byte phm;
public ushort spt;
}
/// <summary>
/// Amstrad superblock, for PCW
/// Amstrad superblock, for PCW
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AmstradSuperBlock
{
/// <summary>
/// Format ID. 0 single-side, 3 double-side. 1 and 2 are for CPC but they don't use the superblock
/// Format ID. 0 single-side, 3 double-side. 1 and 2 are for CPC but they don't use the superblock
/// </summary>
public byte format;
/// <summary>
/// Gives information about side ordering
/// Gives information about side ordering
/// </summary>
public byte sidedness;
/// <summary>
/// Tracks per side, aka, cylinders
/// Tracks per side, aka, cylinders
/// </summary>
public byte tps;
/// <summary>
/// Sectors per track
/// Sectors per track
/// </summary>
public byte spt;
/// <summary>
/// Physical sector shift
/// Physical sector shift
/// </summary>
public byte psh;
/// <summary>
/// Reserved tracks
/// Reserved tracks
/// </summary>
public byte off;
/// <summary>
/// Block size shift
/// Block size shift
/// </summary>
public byte bsh;
/// <summary>
/// How many blocks does the directory take
/// How many blocks does the directory take
/// </summary>
public byte dirBlocks;
/// <summary>
/// GAP#3 length (intersector)
/// GAP#3 length (intersector)
/// </summary>
public byte gapLen;
/// <summary>
/// GAP#4 length (end-of-track)
/// GAP#4 length (end-of-track)
/// </summary>
public byte formatGap;
/// <summary>
/// Must be 0
/// Must be 0
/// </summary>
public byte zero1;
/// <summary>
/// Must be 0
/// Must be 0
/// </summary>
public byte zero2;
/// <summary>
/// Must be 0
/// Must be 0
/// </summary>
public byte zero3;
/// <summary>
/// Must be 0
/// Must be 0
/// </summary>
public byte zero4;
/// <summary>
/// Must be 0
/// Must be 0
/// </summary>
public byte zero5;
/// <summary>
/// Indicates machine the boot code following the superblock is designed to boot
/// Indicates machine the boot code following the superblock is designed to boot
/// </summary>
public byte fiddle;
}
/// <summary>
/// Superblock found on CP/M-86 hard disk volumes
/// Superblock found on CP/M-86 hard disk volumes
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct HardDiskSuperBlock
{
/// <summary>
/// Value so the sum of all the superblock's sector bytes taken as 16-bit values gives 0
/// Value so the sum of all the superblock's sector bytes taken as 16-bit values gives 0
/// </summary>
public ushort checksum;
/// <summary>
/// Copyright string
/// Copyright string
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1F)] public byte[] copyright;
/// <summary>
/// First cylinder of disk where this volume resides
/// First cylinder of disk where this volume resides
/// </summary>
public ushort firstCylinder;
/// <summary>
/// How many cylinders does this volume span
/// How many cylinders does this volume span
/// </summary>
public ushort cylinders;
/// <summary>
/// Heads on hard disk
/// Heads on hard disk
/// </summary>
public byte heads;
/// <summary>
/// Sectors per track
/// Sectors per track
/// </summary>
public byte sectorsPerTrack;
/// <summary>
/// Flags, only use by CCP/M where bit 0 equals verify on write
/// Flags, only use by CCP/M where bit 0 equals verify on write
/// </summary>
public byte flags;
/// <summary>
/// Sector size / 128
/// Sector size / 128
/// </summary>
public byte recordsPerSector;
/// <summary>
/// <see cref="DiscParameterBlock.spt"/>
/// <see cref="DiscParameterBlock.spt" />
/// </summary>
public ushort spt;
/// <summary>
/// <see cref="DiscParameterBlock.bsh"/>
/// <see cref="DiscParameterBlock.bsh" />
/// </summary>
public byte bsh;
/// <summary>
/// <see cref="DiscParameterBlock.blm"/>
/// <see cref="DiscParameterBlock.blm" />
/// </summary>
public byte blm;
/// <summary>
/// <see cref="DiscParameterBlock.exm"/>
/// <see cref="DiscParameterBlock.exm" />
/// </summary>
public byte exm;
/// <summary>
/// <see cref="DiscParameterBlock.dsm"/>
/// <see cref="DiscParameterBlock.dsm" />
/// </summary>
public ushort dsm;
/// <summary>
/// <see cref="DiscParameterBlock.drm"/>
/// <see cref="DiscParameterBlock.drm" />
/// </summary>
public ushort drm;
/// <summary>
/// <see cref="DiscParameterBlock.al0"/>
/// <see cref="DiscParameterBlock.al0" />
/// </summary>
public ushort al0;
/// <summary>
/// <see cref="DiscParameterBlock.al1"/>
/// <see cref="DiscParameterBlock.al1" />
/// </summary>
public ushort al1;
/// <summary>
/// <see cref="DiscParameterBlock.cks"/>
/// <see cref="DiscParameterBlock.cks" />
/// </summary>
public ushort cks;
/// <summary>
/// <see cref="DiscParameterBlock.off"/>
/// <see cref="DiscParameterBlock.off" />
/// </summary>
public ushort off;
/// <summary>
/// Must be zero
/// Must be zero
/// </summary>
public ushort zero1;
/// <summary>
/// Must be zero
/// Must be zero
/// </summary>
public ushort zero2;
/// <summary>
/// Must be zero
/// Must be zero
/// </summary>
public ushort zero3;
/// <summary>
/// Must be zero
/// Must be zero
/// </summary>
public ushort zero4;
/// <summary>
/// How many 128 bytes are in a block
/// How many 128 bytes are in a block
/// </summary>
public ushort recordsPerBlock;
/// <summary>
/// Maximum number of bad blocks in the bad block list
/// Maximum number of bad blocks in the bad block list
/// </summary>
public ushort badBlockWordsMax;
/// <summary>
/// Used number of bad blocks in the bad block list
/// Used number of bad blocks in the bad block list
/// </summary>
public ushort badBlockWords;
/// <summary>
/// First block after the blocks reserved for bad block substitution
/// First block after the blocks reserved for bad block substitution
/// </summary>
public ushort firstSub;
}
/// <summary>
/// Volume label entry
/// Volume label entry
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct LabelEntry
{
/// <summary>
/// Must be 0x20
/// Must be 0x20
/// </summary>
public byte signature;
/// <summary>
/// Label in ASCII
/// Label in ASCII
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] public byte[] label;
/// <summary>
/// Label flags. Bit 0 = label exists, bit 4 = creation timestamp, bit 5 = modification timestamp, bit 6 = access timestamp, bit 7 = password enabled
/// Label flags. Bit 0 = label exists, bit 4 = creation timestamp, bit 5 = modification timestamp, bit 6 = access
/// timestamp, bit 7 = password enabled
/// </summary>
public byte flags;
/// <summary>
/// Password decoder byte
/// Password decoder byte
/// </summary>
public byte passwordDecoder;
/// <summary>
/// Must be 0
/// Must be 0
/// </summary>
public ushort reserved;
/// <summary>
/// Password XOR'ed with <see cref="passwordDecoder"/>
/// Password XOR'ed with <see cref="passwordDecoder" />
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] password;
/// <summary>
/// Label creation time
/// Label creation time
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] ctime;
/// <summary>
/// Label modification time
/// Label modification time
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] mtime;
}
/// <summary>
/// CP/M 3 timestamp entry
/// CP/M 3 timestamp entry
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct DateEntry
{
/// <summary>
/// Must be 0x21
/// Must be 0x21
/// </summary>
public byte signature;
/// <summary>
/// File 1 create/access timestamp
/// File 1 create/access timestamp
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] date1;
/// <summary>
/// File 1 modification timestamp
/// File 1 modification timestamp
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] date2;
/// <summary>
/// File 1 password mode
/// File 1 password mode
/// </summary>
public byte mode1;
public byte zero1;
/// <summary>
/// File 2 create/access timestamp
/// File 2 create/access timestamp
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] date3;
/// <summary>
/// File 2 modification timestamp
/// File 2 modification timestamp
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] date4;
/// <summary>
/// File 2 password mode
/// File 2 password mode
/// </summary>
public byte mode2;
public byte zero2;
/// <summary>
/// File 3 create/access timestamp
/// File 3 create/access timestamp
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] date5;
/// <summary>
/// File 3 modification timestamp
/// File 3 modification timestamp
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] date6;
/// <summary>
/// File 3 password mode
/// File 3 password mode
/// </summary>
public byte mode3;
public ushort zero3;
}
/// <summary>
/// Password entry
/// Password entry
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct PasswordEntry
{
/// <summary>
/// 16 + user number
/// 16 + user number
/// </summary>
public byte userNumber;
/// <summary>
/// Filename
/// Filename
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] filename;
/// <summary>
/// Extension
/// Extension
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] extension;
/// <summary>
/// Password mode. Bit 7 = required for read, bit 6 = required for write, bit 5 = required for delete
/// Password mode. Bit 7 = required for read, bit 6 = required for write, bit 5 = required for delete
/// </summary>
public byte mode;
/// <summary>
/// Password decoder byte
/// Password decoder byte
/// </summary>
public byte passwordDecoder;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] reserved;
/// <summary>
/// Password XOR'ed with <see cref="passwordDecoder"/>
/// Password XOR'ed with <see cref="passwordDecoder" />
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] password;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] reserved2;
}
/// <summary>
/// Timestamp for Z80DOS or DOS+
/// Timestamp for Z80DOS or DOS+
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct TrdPartyDateEntry
{
/// <summary>
/// Must be 0x21
/// Must be 0x21
/// </summary>
public byte signature;
public byte zero;
/// <summary>
/// Creation year for file 1
/// Creation year for file 1
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] create1;
/// <summary>
/// Modification time for file 1
/// Modification time for file 1
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] modify1;
/// <summary>
/// Access time for file 1
/// Access time for file 1
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] access1;
/// <summary>
/// Creation year for file 2
/// Creation year for file 2
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] create2;
/// <summary>
/// Modification time for file 2
/// Modification time for file 2
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] modify2;
/// <summary>
/// Access time for file 2
/// Access time for file 2
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] access2;
/// <summary>
/// Creation year for file 3
/// Creation year for file 3
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] create3;
/// <summary>
/// Modification time for file 3
/// Modification time for file 3
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] modify3;
/// <summary>
/// Access time for file 3
/// Access time for file 3
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] access3;
}
/// <summary>
/// Directory entry for &lt;256 allocation blocks
/// Directory entry for &lt;256 allocation blocks
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct DirectoryEntry
{
/// <summary>
/// User number. Bit 7 set in CP/M 1 means hidden
/// User number. Bit 7 set in CP/M 1 means hidden
/// </summary>
public byte statusUser;
/// <summary>
/// Filename and bit 7 as flags
/// Filename and bit 7 as flags
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] filename;
/// <summary>
/// Extension and bit 7 as flags
/// Extension and bit 7 as flags
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] extension;
/// <summary>
/// Low byte of extent number
/// Low byte of extent number
/// </summary>
public byte extentCounter;
/// <summary>
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how many bytes are free.
/// It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how many
/// bytes are free.
/// It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
/// </summary>
public byte lastRecordBytes;
/// <summary>
/// High byte of extent number
/// High byte of extent number
/// </summary>
public byte extentCounterHigh;
/// <summary>
/// How many records are used in this entry. 0x80 if all are used.
/// How many records are used in this entry. 0x80 if all are used.
/// </summary>
public byte records;
/// <summary>
/// Allocation blocks
/// Allocation blocks
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] allocations;
}
/// <summary>
/// Directory entry for &gt;256 allocation blocks
/// Directory entry for &gt;256 allocation blocks
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct DirectoryEntry16
{
/// <summary>
/// User number. Bit 7 set in CP/M 1 means hidden
/// User number. Bit 7 set in CP/M 1 means hidden
/// </summary>
public byte statusUser;
/// <summary>
/// Filename and bit 7 as flags
/// Filename and bit 7 as flags
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] filename;
/// <summary>
/// Extension and bit 7 as flags
/// Extension and bit 7 as flags
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] extension;
/// <summary>
/// Low byte of extent number
/// Low byte of extent number
/// </summary>
public byte extentCounter;
/// <summary>
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how many bytes are free.
/// It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how many
/// bytes are free.
/// It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
/// </summary>
public byte lastRecordBytes;
/// <summary>
/// High byte of extent number
/// High byte of extent number
/// </summary>
public byte extentCounterHigh;
/// <summary>
/// How many records are used in this entry. 0x80 if all are used.
/// How many records are used in this entry. 0x80 if all are used.
/// </summary>
public byte records;
/// <summary>
/// Allocation blocks
/// Allocation blocks
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public ushort[] allocations;
}