mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Final cleanup of DiscImageChef.Filesystems.
This commit is contained in:
@@ -48,15 +48,15 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
const byte EMPTY_STORAGE_TYPE = 0x00;
|
||||
/// <summary>
|
||||
/// A file that occupies one block or less
|
||||
/// A file that occupies one block or less
|
||||
/// </summary>
|
||||
const byte SEEDLING_FILE_TYPE = 0x01;
|
||||
/// <summary>
|
||||
/// A file that occupies between 2 and 256 blocks
|
||||
/// A file that occupies between 2 and 256 blocks
|
||||
/// </summary>
|
||||
const byte SAPLING_FILE_TYPE = 0x02;
|
||||
/// <summary>
|
||||
/// A file that occupies between 257 and 32768 blocks
|
||||
/// A file that occupies between 257 and 32768 blocks
|
||||
/// </summary>
|
||||
const byte TREE_FILE_TYPE = 0x03;
|
||||
const byte PASCAL_AREA_TYPE = 0x04;
|
||||
@@ -120,9 +120,21 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
byte[] tmp = imagePlugin.ReadSectors(partition.Start, 2);
|
||||
|
||||
foreach(int offset in new[] {0, 0x200, 0x400, 0x600, 0x800, 0xA00}.Where(offset => BitConverter.ToUInt16(tmp, offset) == 0 &&
|
||||
(byte)((tmp[offset + 0x04] & STORAGE_TYPE_MASK) >> 4) == ROOT_DIRECTORY_TYPE &&
|
||||
tmp[offset + 0x23] == ENTRY_LENGTH && tmp[offset + 0x24] == ENTRIES_PER_BLOCK)) {
|
||||
foreach(int offset in new[] {0, 0x200, 0x400, 0x600, 0x800, 0xA00}.Where(offset =>
|
||||
BitConverter
|
||||
.ToUInt16(tmp,
|
||||
offset) ==
|
||||
0 &&
|
||||
(byte)
|
||||
((tmp[offset + 0x04] &
|
||||
STORAGE_TYPE_MASK) >>
|
||||
4) ==
|
||||
ROOT_DIRECTORY_TYPE &&
|
||||
tmp[offset + 0x23] ==
|
||||
ENTRY_LENGTH &&
|
||||
tmp[offset + 0x24] ==
|
||||
ENTRIES_PER_BLOCK))
|
||||
{
|
||||
Array.Copy(tmp, offset, rootDirectoryKeyBlock, 0, 0x200);
|
||||
APMFromHDDOnCD = true;
|
||||
break;
|
||||
@@ -157,8 +169,7 @@ namespace DiscImageChef.Filesystems
|
||||
return totalBlocks <= partition.End - partition.Start + 1;
|
||||
}
|
||||
|
||||
public override void GetInformation(ImagePlugin imagePlugin, Partition partition,
|
||||
out string information)
|
||||
public override void GetInformation(ImagePlugin imagePlugin, Partition partition, out string information)
|
||||
{
|
||||
StringBuilder sbInformation = new StringBuilder();
|
||||
|
||||
@@ -172,9 +183,21 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
byte[] tmp = imagePlugin.ReadSectors(partition.Start, 2);
|
||||
|
||||
foreach(int offset in new[] {0, 0x200, 0x400, 0x600, 0x800, 0xA00}.Where(offset => BitConverter.ToUInt16(tmp, offset) == 0 &&
|
||||
(byte)((tmp[offset + 0x04] & STORAGE_TYPE_MASK) >> 4) == ROOT_DIRECTORY_TYPE &&
|
||||
tmp[offset + 0x23] == ENTRY_LENGTH && tmp[offset + 0x24] == ENTRIES_PER_BLOCK)) {
|
||||
foreach(int offset in new[] {0, 0x200, 0x400, 0x600, 0x800, 0xA00}.Where(offset =>
|
||||
BitConverter
|
||||
.ToUInt16(tmp,
|
||||
offset) ==
|
||||
0 &&
|
||||
(byte)
|
||||
((tmp[offset + 0x04] &
|
||||
STORAGE_TYPE_MASK) >>
|
||||
4) ==
|
||||
ROOT_DIRECTORY_TYPE &&
|
||||
tmp[offset + 0x23] ==
|
||||
ENTRY_LENGTH &&
|
||||
tmp[offset + 0x24] ==
|
||||
ENTRIES_PER_BLOCK))
|
||||
{
|
||||
Array.Copy(tmp, offset, rootDirectoryKeyBlockBytes, 0, 0x200);
|
||||
APMFromHDDOnCD = true;
|
||||
break;
|
||||
@@ -235,8 +258,7 @@ namespace DiscImageChef.Filesystems
|
||||
sbInformation.AppendLine("ProDOS uses 512 bytes/sector while devices uses 2048 bytes/sector.")
|
||||
.AppendLine();
|
||||
|
||||
if(rootDirectoryKeyBlock.header.version != VERSION1 ||
|
||||
rootDirectoryKeyBlock.header.min_version != VERSION1)
|
||||
if(rootDirectoryKeyBlock.header.version != VERSION1 || rootDirectoryKeyBlock.header.min_version != VERSION1)
|
||||
{
|
||||
sbInformation.AppendLine("Warning! Detected unknown ProDOS version ProDOS filesystem.");
|
||||
sbInformation.AppendLine("All of the following information may be incorrect");
|
||||
@@ -363,80 +385,80 @@ namespace DiscImageChef.Filesystems
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ProDOS directory entry, decoded structure
|
||||
/// ProDOS directory entry, decoded structure
|
||||
/// </summary>
|
||||
struct ProDOSEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of file pointed by this entry
|
||||
/// Offset 0x00, mask 0xF0
|
||||
/// Type of file pointed by this entry
|
||||
/// Offset 0x00, mask 0xF0
|
||||
/// </summary>
|
||||
public byte storage_type;
|
||||
/// <summary>
|
||||
/// Length of name_length pascal string
|
||||
/// Offset 0x00, mask 0x0F
|
||||
/// Length of name_length pascal string
|
||||
/// Offset 0x00, mask 0x0F
|
||||
/// </summary>
|
||||
public byte name_length;
|
||||
/// <summary>
|
||||
/// Pascal string of file name
|
||||
/// Offset 0x01, 15 bytes
|
||||
/// Pascal string of file name
|
||||
/// Offset 0x01, 15 bytes
|
||||
/// </summary>
|
||||
public string file_name;
|
||||
/// <summary>
|
||||
/// Descriptor of internal structure of the file
|
||||
/// Offset 0x10, 1 byte
|
||||
/// Descriptor of internal structure of the file
|
||||
/// Offset 0x10, 1 byte
|
||||
/// </summary>
|
||||
public byte file_type;
|
||||
/// <summary>
|
||||
/// Block address of master index block for tree files.
|
||||
/// Block address of index block for sapling files.
|
||||
/// Block address of block for seedling files.
|
||||
/// Offset 0x11, 2 bytes
|
||||
/// Block address of master index block for tree files.
|
||||
/// Block address of index block for sapling files.
|
||||
/// Block address of block for seedling files.
|
||||
/// Offset 0x11, 2 bytes
|
||||
/// </summary>
|
||||
public ushort key_pointer;
|
||||
/// <summary>
|
||||
/// Blocks used by file or directory, including index blocks.
|
||||
/// Offset 0x13, 2 bytes
|
||||
/// Blocks used by file or directory, including index blocks.
|
||||
/// Offset 0x13, 2 bytes
|
||||
/// </summary>
|
||||
public ushort blocks_used;
|
||||
/// <summary>
|
||||
/// Size of file in bytes
|
||||
/// Offset 0x15, 3 bytes
|
||||
/// Size of file in bytes
|
||||
/// Offset 0x15, 3 bytes
|
||||
/// </summary>
|
||||
public uint EOF;
|
||||
/// <summary>
|
||||
/// File creation datetime
|
||||
/// Offset 0x18, 4 bytes
|
||||
/// File creation datetime
|
||||
/// Offset 0x18, 4 bytes
|
||||
/// </summary>
|
||||
public DateTime creation_time;
|
||||
/// <summary>
|
||||
/// Version of ProDOS that created this file
|
||||
/// Offset 0x1C, 1 byte
|
||||
/// Version of ProDOS that created this file
|
||||
/// Offset 0x1C, 1 byte
|
||||
/// </summary>
|
||||
public byte version;
|
||||
/// <summary>
|
||||
/// Minimum version of ProDOS needed to access this file
|
||||
/// Offset 0x1D, 1 byte
|
||||
/// Minimum version of ProDOS needed to access this file
|
||||
/// Offset 0x1D, 1 byte
|
||||
/// </summary>
|
||||
public byte min_version;
|
||||
/// <summary>
|
||||
/// File permissions
|
||||
/// Offset 0x1E, 1 byte
|
||||
/// File permissions
|
||||
/// Offset 0x1E, 1 byte
|
||||
/// </summary>
|
||||
public byte access;
|
||||
/// <summary>
|
||||
/// General purpose field to store additional information about file format
|
||||
/// Offset 0x1F, 2 bytes
|
||||
/// General purpose field to store additional information about file format
|
||||
/// Offset 0x1F, 2 bytes
|
||||
/// </summary>
|
||||
public ushort aux_type;
|
||||
/// <summary>
|
||||
/// File last modification date time
|
||||
/// Offset 0x21, 4 bytes
|
||||
/// File last modification date time
|
||||
/// Offset 0x21, 4 bytes
|
||||
/// </summary>
|
||||
public DateTime last_mod;
|
||||
/// <summary>
|
||||
/// Block address pointer to key block of the directory containing this entry
|
||||
/// Offset 0x25, 2 bytes
|
||||
/// Block address pointer to key block of the directory containing this entry
|
||||
/// Offset 0x25, 2 bytes
|
||||
/// </summary>
|
||||
public ushort header_pointer;
|
||||
}
|
||||
@@ -444,71 +466,71 @@ namespace DiscImageChef.Filesystems
|
||||
struct ProDOSRootDirectoryHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Constant 0x0F
|
||||
/// Offset 0x04, mask 0xF0
|
||||
/// Constant 0x0F
|
||||
/// Offset 0x04, mask 0xF0
|
||||
/// </summary>
|
||||
public byte storage_type;
|
||||
/// <summary>
|
||||
/// Length of volume_name pascal string
|
||||
/// Offset 0x04, mask 0x0F
|
||||
/// Length of volume_name pascal string
|
||||
/// Offset 0x04, mask 0x0F
|
||||
/// </summary>
|
||||
public byte name_length;
|
||||
/// <summary>
|
||||
/// The name of the volume.
|
||||
/// Offset 0x05, 15 bytes
|
||||
/// The name of the volume.
|
||||
/// Offset 0x05, 15 bytes
|
||||
/// </summary>
|
||||
public string volume_name;
|
||||
/// <summary>
|
||||
/// Reserved for future expansion
|
||||
/// Offset 0x14, 8 bytes
|
||||
/// Reserved for future expansion
|
||||
/// Offset 0x14, 8 bytes
|
||||
/// </summary>
|
||||
public ulong reserved;
|
||||
/// <summary>
|
||||
/// Creation time of the volume
|
||||
/// Offset 0x1C, 4 bytes
|
||||
/// Creation time of the volume
|
||||
/// Offset 0x1C, 4 bytes
|
||||
/// </summary>
|
||||
public DateTime creation_time;
|
||||
/// <summary>
|
||||
/// Version number of the volume format
|
||||
/// Offset 0x20, 1 byte
|
||||
/// Version number of the volume format
|
||||
/// Offset 0x20, 1 byte
|
||||
/// </summary>
|
||||
public byte version;
|
||||
/// <summary>
|
||||
/// Reserved for future use
|
||||
/// Offset 0x21, 1 byte
|
||||
/// Reserved for future use
|
||||
/// Offset 0x21, 1 byte
|
||||
/// </summary>
|
||||
public byte min_version;
|
||||
/// <summary>
|
||||
/// Permissions for the volume
|
||||
/// Offset 0x22, 1 byte
|
||||
/// Permissions for the volume
|
||||
/// Offset 0x22, 1 byte
|
||||
/// </summary>
|
||||
public byte access;
|
||||
/// <summary>
|
||||
/// Length of an entry in this directory
|
||||
/// Const 0x27
|
||||
/// Offset 0x23, 1 byte
|
||||
/// Length of an entry in this directory
|
||||
/// Const 0x27
|
||||
/// Offset 0x23, 1 byte
|
||||
/// </summary>
|
||||
public byte entry_length;
|
||||
/// <summary>
|
||||
/// Number of entries per block
|
||||
/// Const 0x0D
|
||||
/// Offset 0x24, 1 byte
|
||||
/// Number of entries per block
|
||||
/// Const 0x0D
|
||||
/// Offset 0x24, 1 byte
|
||||
/// </summary>
|
||||
public byte entries_per_block;
|
||||
/// <summary>
|
||||
/// Number of active files in this directory
|
||||
/// Offset 0x25, 2 bytes
|
||||
/// Number of active files in this directory
|
||||
/// Offset 0x25, 2 bytes
|
||||
/// </summary>
|
||||
public ushort file_count;
|
||||
/// <summary>
|
||||
/// Block address of the first block of the volume's bitmap,
|
||||
/// one for every 4096 blocks or fraction
|
||||
/// Offset 0x27, 2 bytes
|
||||
/// Block address of the first block of the volume's bitmap,
|
||||
/// one for every 4096 blocks or fraction
|
||||
/// Offset 0x27, 2 bytes
|
||||
/// </summary>
|
||||
public ushort bit_map_pointer;
|
||||
/// <summary>
|
||||
/// Total number of blocks in the volume
|
||||
/// Offset 0x29, 2 bytes
|
||||
/// Total number of blocks in the volume
|
||||
/// Offset 0x29, 2 bytes
|
||||
/// </summary>
|
||||
public ushort total_blocks;
|
||||
}
|
||||
@@ -516,76 +538,76 @@ namespace DiscImageChef.Filesystems
|
||||
struct ProDOSDirectoryHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Constant 0x0E
|
||||
/// Offset 0x04, mask 0xF0
|
||||
/// Constant 0x0E
|
||||
/// Offset 0x04, mask 0xF0
|
||||
/// </summary>
|
||||
public byte storage_type;
|
||||
/// <summary>
|
||||
/// Length of volume_name pascal string
|
||||
/// Offset 0x04, mask 0x0F
|
||||
/// Length of volume_name pascal string
|
||||
/// Offset 0x04, mask 0x0F
|
||||
/// </summary>
|
||||
public byte name_length;
|
||||
/// <summary>
|
||||
/// The name of the directory.
|
||||
/// Offset 0x05, 15 bytes
|
||||
/// The name of the directory.
|
||||
/// Offset 0x05, 15 bytes
|
||||
/// </summary>
|
||||
public string directory_name;
|
||||
/// <summary>
|
||||
/// Reserved for future expansion
|
||||
/// Offset 0x14, 8 bytes
|
||||
/// Reserved for future expansion
|
||||
/// Offset 0x14, 8 bytes
|
||||
/// </summary>
|
||||
public ulong reserved;
|
||||
/// <summary>
|
||||
/// Creation time of the volume
|
||||
/// Offset 0x1C, 4 bytes
|
||||
/// Creation time of the volume
|
||||
/// Offset 0x1C, 4 bytes
|
||||
/// </summary>
|
||||
public DateTime creation_time;
|
||||
/// <summary>
|
||||
/// Version number of the volume format
|
||||
/// Offset 0x20, 1 byte
|
||||
/// Version number of the volume format
|
||||
/// Offset 0x20, 1 byte
|
||||
/// </summary>
|
||||
public byte version;
|
||||
/// <summary>
|
||||
/// Reserved for future use
|
||||
/// Offset 0x21, 1 byte
|
||||
/// Reserved for future use
|
||||
/// Offset 0x21, 1 byte
|
||||
/// </summary>
|
||||
public byte min_version;
|
||||
/// <summary>
|
||||
/// Permissions for the volume
|
||||
/// Offset 0x22, 1 byte
|
||||
/// Permissions for the volume
|
||||
/// Offset 0x22, 1 byte
|
||||
/// </summary>
|
||||
public byte access;
|
||||
/// <summary>
|
||||
/// Length of an entry in this directory
|
||||
/// Const 0x27
|
||||
/// Offset 0x23, 1 byte
|
||||
/// Length of an entry in this directory
|
||||
/// Const 0x27
|
||||
/// Offset 0x23, 1 byte
|
||||
/// </summary>
|
||||
public byte entry_length;
|
||||
/// <summary>
|
||||
/// Number of entries per block
|
||||
/// Const 0x0D
|
||||
/// Offset 0x24, 1 byte
|
||||
/// Number of entries per block
|
||||
/// Const 0x0D
|
||||
/// Offset 0x24, 1 byte
|
||||
/// </summary>
|
||||
public byte entries_per_block;
|
||||
/// <summary>
|
||||
/// Number of active files in this directory
|
||||
/// Offset 0x25, 2 bytes
|
||||
/// Number of active files in this directory
|
||||
/// Offset 0x25, 2 bytes
|
||||
/// </summary>
|
||||
public ushort file_count;
|
||||
/// <summary>
|
||||
/// Block address of parent directory block that contains this entry
|
||||
/// Offset 0x27, 2 bytes
|
||||
/// Block address of parent directory block that contains this entry
|
||||
/// Offset 0x27, 2 bytes
|
||||
/// </summary>
|
||||
public ushort parent_pointer;
|
||||
/// <summary>
|
||||
/// Entry number within the block indicated in parent_pointer
|
||||
/// Offset 0x29, 1 byte
|
||||
/// Entry number within the block indicated in parent_pointer
|
||||
/// Offset 0x29, 1 byte
|
||||
/// </summary>
|
||||
public byte parent_entry_number;
|
||||
/// <summary>
|
||||
/// Length of the entry that holds this directory, in the parent entry
|
||||
/// Const 0x27
|
||||
/// Offset 0x2A, 1 byte
|
||||
/// Length of the entry that holds this directory, in the parent entry
|
||||
/// Const 0x27
|
||||
/// Offset 0x2A, 1 byte
|
||||
/// </summary>
|
||||
public byte parent_entry_length;
|
||||
}
|
||||
@@ -593,23 +615,23 @@ namespace DiscImageChef.Filesystems
|
||||
struct ProDOSDirectoryKeyBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Always 0
|
||||
/// Offset 0x00, 2 bytes
|
||||
/// Always 0
|
||||
/// Offset 0x00, 2 bytes
|
||||
/// </summary>
|
||||
public ushort zero;
|
||||
/// <summary>
|
||||
/// Pointer to next directory block, 0 if last
|
||||
/// Offset 0x02, 2 bytes
|
||||
/// Pointer to next directory block, 0 if last
|
||||
/// Offset 0x02, 2 bytes
|
||||
/// </summary>
|
||||
public ushort next_pointer;
|
||||
/// <summary>
|
||||
/// Directory header
|
||||
/// Offset 0x04, 39 bytes
|
||||
/// Directory header
|
||||
/// Offset 0x04, 39 bytes
|
||||
/// </summary>
|
||||
public ProDOSDirectoryHeader header;
|
||||
/// <summary>
|
||||
/// Directory entries
|
||||
/// Offset 0x2F, 39 bytes each, 12 entries
|
||||
/// Directory entries
|
||||
/// Offset 0x2F, 39 bytes each, 12 entries
|
||||
/// </summary>
|
||||
public ProDOSEntry[] entries;
|
||||
}
|
||||
@@ -617,23 +639,23 @@ namespace DiscImageChef.Filesystems
|
||||
struct ProDOSRootDirectoryKeyBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Always 0
|
||||
/// Offset 0x00, 2 bytes
|
||||
/// Always 0
|
||||
/// Offset 0x00, 2 bytes
|
||||
/// </summary>
|
||||
public ushort zero;
|
||||
/// <summary>
|
||||
/// Pointer to next directory block, 0 if last
|
||||
/// Offset 0x02, 2 bytes
|
||||
/// Pointer to next directory block, 0 if last
|
||||
/// Offset 0x02, 2 bytes
|
||||
/// </summary>
|
||||
public ushort next_pointer;
|
||||
/// <summary>
|
||||
/// Directory header
|
||||
/// Offset 0x04, 39 bytes
|
||||
/// Directory header
|
||||
/// Offset 0x04, 39 bytes
|
||||
/// </summary>
|
||||
public ProDOSRootDirectoryHeader header;
|
||||
/// <summary>
|
||||
/// Directory entries
|
||||
/// Offset 0x2F, 39 bytes each, 12 entries
|
||||
/// Directory entries
|
||||
/// Offset 0x2F, 39 bytes each, 12 entries
|
||||
/// </summary>
|
||||
public ProDOSEntry[] entries;
|
||||
}
|
||||
@@ -641,18 +663,18 @@ namespace DiscImageChef.Filesystems
|
||||
struct ProDOSDirectoryBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Pointer to previous directory block
|
||||
/// Offset 0x00, 2 bytes
|
||||
/// Pointer to previous directory block
|
||||
/// Offset 0x00, 2 bytes
|
||||
/// </summary>
|
||||
public ushort zero;
|
||||
/// <summary>
|
||||
/// Pointer to next directory block, 0 if last
|
||||
/// Offset 0x02, 2 bytes
|
||||
/// Pointer to next directory block, 0 if last
|
||||
/// Offset 0x02, 2 bytes
|
||||
/// </summary>
|
||||
public ushort next_pointer;
|
||||
/// <summary>
|
||||
/// Directory entries
|
||||
/// Offset 0x2F, 39 bytes each, 13 entries
|
||||
/// Directory entries
|
||||
/// Offset 0x2F, 39 bytes each, 13 entries
|
||||
/// </summary>
|
||||
public ProDOSEntry[] entries;
|
||||
}
|
||||
@@ -660,7 +682,7 @@ namespace DiscImageChef.Filesystems
|
||||
struct ProDOSIndexBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Up to 256 pointers to blocks, 0 to indicate the block is sparsed (non-allocated)
|
||||
/// Up to 256 pointers to blocks, 0 to indicate the block is sparsed (non-allocated)
|
||||
/// </summary>
|
||||
public ushort[] block_pointer;
|
||||
}
|
||||
@@ -668,7 +690,7 @@ namespace DiscImageChef.Filesystems
|
||||
struct ProDOSMasterIndexBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Up to 128 pointers to index blocks
|
||||
/// Up to 128 pointers to index blocks
|
||||
/// </summary>
|
||||
public ushort[] index_block_pointer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user