Files
Aaru/Aaru.Filesystems/ProDOS.cs

510 lines
23 KiB
C#
Raw Normal View History

// /***************************************************************************
2020-02-27 12:31:25 +00:00
// Aaru Data Preservation Suite
* LICENSE.MIT: * LICENSE.LGPL: Added LICENSE files for LGPL and MIT licenses. * DiscImageChef.Devices/Enums.cs: * DiscImageChef.Partitions/MBR.cs: * DiscImageChef.Partitions/RDB.cs: * DiscImageChef.DiscImages/GDI.cs: * DiscImageChef.Partitions/Sun.cs: * DiscImageChef.DiscImages/VHD.cs: * DiscImageChef.Partitions/GPT.cs: * DiscImageChef.Filesystems/FFS.cs: * DiscImageChef.Filesystems/FAT.cs: * DiscImageChef.Partitions/NeXT.cs: * DiscImageChef.Devices/Command.cs: * DiscImageChef.DiscImages/Nero.cs: * DiscImageChef.Decoders/CD/PMA.cs: * DiscImageChef.Decoders/CD/TOC.cs: * DiscImageChef.Filesystems/BFS.cs: * DiscImageChef.Filesystems/ODS.cs: * DiscImageChef.Helpers/PrintHex.cs: * DiscImageChef.Helpers/Swapping.cs: * DiscImageChef.Decoders/DVD/PRI.cs: * DiscImageChef.Decoders/DVD/DMI.cs: * DiscImageChef.Decoders/DVD/DDS.cs: * DiscImageChef.Decoders/DVD/RMD.cs: * DiscImageChef.Decoders/DVD/UDI.cs: * DiscImageChef.Partitions/Atari.cs: * DiscImageChef.Decoders/DVD/BCA.cs: * DiscImageChef.Filesystems/SysV.cs: * DiscImageChef.Filesystems/HPFS.cs: * DiscImageChef.Filesystems/NTFS.cs: * DiscImageChef.Filesystems/APFS.cs: * DiscImageChef.Decoders/DVD/PFI.cs: * DiscImageChef.Decoders/CD/ATIP.cs: * DiscImageChef.Filesystems/Acorn.cs: * DiscImageChef.DiscImages/CDRWin.cs: * DiscImageChef.DiscImages/CDRDAO.cs: * DiscImageChef.Filesystems/BTRFS.cs: * DiscImageChef.Decoders/Xbox/DMI.cs: * DiscImageChef.Helpers/ArrayFill.cs: * DiscImageChef.Settings/Settings.cs: * DiscImageChef.Filesystems/Opera.cs: * DiscImageChef.Filesystems/extFS.cs: * DiscImageChef.Decoders/DVD/CPRM.cs: * DiscImageChef.Decoders/DVD/ADIP.cs: * DiscImageChef.Decoders/CD/Enums.cs: * DiscImageChef.Decoders/DVD/AACS.cs: * DiscImageChef.Decoders/SCSI/EVPD.cs: * DiscImageChef.Filesystems/ProDOS.cs: * DiscImageChef.Metadata/MediaType.cs: * DiscImageChef.Console/DicConsole.cs: * DiscImageChef.Decoders/DVD/Spare.cs: * DiscImageChef.Filesystems/ext2FS.cs: * DiscImageChef.Decoders/DVD/Enums.cs: * DiscImageChef.Filesystems/Symbian.cs: * DiscImageChef.Decoders/SCSI/Types.cs: * DiscImageChef.Filesystems/UNIXBFS.cs: * DiscImageChef.DiscImages/TeleDisk.cs: * DiscImageChef.Decoders/SCSI/Sense.cs: * DiscImageChef.Decoders/CD/FullTOC.cs: * DiscImageChef.Decoders/Blu-ray/DI.cs: * DiscImageChef.Decoders/ATA/Errors.cs: * DiscImageChef.Filesystems/ISO9660.cs: * DiscImageChef.Filesystems/MinixFS.cs: * DiscImageChef.Devices/Linux/Enums.cs: * DiscImageChef.Filesystems/SolarFS.cs: * DiscImageChef.Filesystems/Structs.cs: * DiscImageChef.DiscImages/Apple2MG.cs: * DiscImageChef.Decoders/SCSI/Modes.cs: * DiscImageChef.Metadata/Dimensions.cs: * DiscImageChef.Partitions/AppleMap.cs: * DiscImageChef.Decoders/Floppy/ISO.cs: * DiscImageChef.Decoders/DVD/Layers.cs: * DiscImageChef.Decoders/CD/Session.cs: * DiscImageChef.Decoders/SCSI/Enums.cs: * DiscImageChef.Filesystems/Nintendo.cs: * DiscImageChef.Helpers/DateHandlers.cs: * DiscImageChef.Filesystems/AmigaDOS.cs: * DiscImageChef.DiscImages/ImageInfo.cs: * DiscImageChef.Checksums/MD5Context.cs: * DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Filesystems/AppleHFS.cs: * DiscImageChef.Filesystems/AppleMFS.cs: * DiscImageChef.Helpers/ArrayIsEmpty.cs: * DiscImageChef.Decoders/Blu-ray/BCA.cs: * DiscImageChef.Decoders/Blu-ray/DDS.cs: * DiscImageChef.Filesystems/PCEngine.cs: * DiscImageChef.Decoders/ATA/Identify.cs: * DiscImageChef.Devices/Linux/Command.cs: * DiscImageChef.Devices/FreeBSD/Enums.cs: * DiscImageChef.Decoders/SCSI/Inquiry.cs: * DiscImageChef.Metadata/DeviceReport.cs: * DiscImageChef.Decoders/Floppy/Amiga.cs: * DiscImageChef.Devices/Linux/Structs.cs: * DiscImageChef.Devices/Windows/Enums.cs: * DiscImageChef.Decoders/DVD/CSS&CPRM.cs: * DiscImageChef.Checksums/SHA1Context.cs: * DiscImageChef.DiscImages/DiskCopy42.cs: * DiscImageChef.Partitions/PartPlugin.cs: * DiscImageChef.CommonTypes/Partition.cs: * DiscImageChef.Decoders/Floppy/Enums.cs: * DiscImageChef.CommonTypes/MediaType.cs: * DiscImageChef.Decoders/Floppy/Apple2.cs: * DiscImageChef.Devices/Windows/Extern.cs: * DiscImageChef.Decoders/SCSI/MMC/CPRM.cs: * DiscImageChef.Helpers/StringHandlers.cs: * DiscImageChef.DiscImages/ImagePlugin.cs: * DiscImageChef.Checksums/CRC64Context.cs: * DiscImageChef.Checksums/CRC32Context.cs: * DiscImageChef.DiscImages/ZZZRawImage.cs: * DiscImageChef.Checksums/CRC16Context.cs: * DiscImageChef.Filesystems/LisaFS/Dir.cs: * DiscImageChef.Decoders/DVD/Cartridge.cs: * DiscImageChef.Decoders/Blu-ray/Spare.cs: * DiscImageChef.Filesystems/Filesystem.cs: * DiscImageChef.Decoders/SCSI/MMC/AACS.cs: * DiscImageChef.Devices/FreeBSD/Extern.cs: * DiscImageChef.Devices/Device/Commands.cs: * DiscImageChef.Checksums/SHA384Context.cs: * DiscImageChef.Devices/FreeBSD/Command.cs: * DiscImageChef.Checksums/SHA512Context.cs: * DiscImageChef.Decoders/SCSI/MMC/Enums.cs: * DiscImageChef.Devices/Windows/Command.cs: * DiscImageChef.Devices/FreeBSD/Structs.cs: * DiscImageChef.Devices/Windows/Structs.cs: * DiscImageChef.Filesystems/LisaFS/Info.cs: * DiscImageChef.Checksums/SHA256Context.cs: * DiscImageChef.Filesystems/LisaFS/File.cs: * DiscImageChef.Filesystems/AppleHFSPlus.cs: * DiscImageChef.Filesystems/LisaFS/Super.cs: * DiscImageChef.Filesystems/LisaFS/Xattr.cs: * DiscImageChef.Checksums/Adler32Context.cs: * DiscImageChef.Decoders/Floppy/System34.cs: * DiscImageChef.Checksums/SpamSumContext.cs: * DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs: * DiscImageChef.Devices/Device/Variables.cs: * DiscImageChef.Filesystems/LisaFS/Consts.cs: * DiscImageChef.Filesystems/LisaFS/LisaFS.cs: * DiscImageChef.Decoders/Floppy/Commodore.cs: * DiscImageChef.Checksums/FletcherContext.cs: * DiscImageChef.Filesystems/LisaFS/Extent.cs: * DiscImageChef.Devices/Device/Destructor.cs: * DiscImageChef.Decoders/Floppy/AppleSony.cs: * DiscImageChef.Filesystems/LisaFS/Structs.cs: * DiscImageChef.Decoders/SCSI/VendorString.cs: * DiscImageChef.Decoders/SCSI/MMC/Features.cs: * DiscImageChef.Devices/Device/Constructor.cs: * DiscImageChef.Checksums/RIPEMD160Context.cs: * DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs: * DiscImageChef.Decoders/Blu-ray/Cartridge.cs: * DiscImageChef.Decoders/Floppy/System3740.cs: * DiscImageChef.Filesystems/LisaFS/Encoding.cs: * DiscImageChef.Decoders/SCSI/ModesEncoders.cs: * DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs: * DiscImageChef.Helpers/BigEndianBitConverter.cs: * DiscImageChef.Decoders/Floppy/Perpendicular.cs: * DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs: * DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs: * DiscImageChef.Devices/Device/ScsiCommands/HP.cs: * DiscImageChef.Devices/Device/AtaCommands/Cfa.cs: * DiscImageChef.Devices/Device/ScsiCommands/NEC.cs: * DiscImageChef.Helpers/EndianAwareBinaryReader.cs: * DiscImageChef.Devices/Device/ScsiCommands/MMC.cs: * DiscImageChef.Devices/Device/AtaCommands/MCPT.cs: * DiscImageChef.Devices/Device/ScsiCommands/SSC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SPC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SMC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SBC.cs: * DiscImageChef.Metadata/Properties/AssemblyInfo.cs: * DiscImageChef.Devices/Device/AtaCommands/Atapi.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata28.cs: * DiscImageChef.Devices/Device/AtaCommands/Smart.cs: * DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata48.cs: * DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs: * DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs: * DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs: * DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs: * DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs: * DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs: * DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs: * DiscImageChef.Devices/Device/ScsiCommands/Certance.cs: * DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs: * DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs: Relicensed as LGPL. Updated standard header. * DiscImageChef/Main.cs: * DiscImageChef/Plugins.cs: * DiscImageChef/Options.cs: * DiscImageChef/Commands/Ls.cs: * DiscImageChef/Core/IBGLog.cs: * DiscImageChef/Core/MHDDLog.cs: * DiscImageChef/AssemblyInfo.cs: * DiscImageChef/Core/Checksum.cs: * DiscImageChef/Commands/Decode.cs: * DiscImageChef/Core/Statistics.cs: * DiscImageChef/Commands/Verify.cs: * DiscImageChef/Commands/Formats.cs: * DiscImageChef/Commands/Entropy.cs: * DiscImageChef/Commands/Compare.cs: * DiscImageChef.Interop/DetectOS.cs: * DiscImageChef/Commands/Analyze.cs: * DiscImageChef/Commands/Commands.cs: * DiscImageChef/Commands/PrintHex.cs: * DiscImageChef/Commands/Checksum.cs: * DiscImageChef/DetectImageFormat.cs: * DiscImageChef/Commands/DumpMedia.cs: * DiscImageChef/Commands/Benchmark.cs: * DiscImageChef/Commands/Configure.cs: * DiscImageChef/Commands/MediaInfo.cs: * DiscImageChef.Interop/PlatformID.cs: * DiscImageChef/Commands/MediaScan.cs: * DiscImageChef/Commands/Statistics.cs: * DiscImageChef/Commands/DeviceInfo.cs: * DiscImageChef.Checksums/ReedSolomon.cs: * DiscImageChef/Commands/DeviceReport.cs: * DiscImageChef/Commands/ExtractFiles.cs: * DiscImageChef.Checksums/CDChecksums.cs: * DiscImageChef/Commands/CreateSidecar.cs: Updated standard header. * DiscImageChef.Checksums/DiscImageChef.Checksums.csproj: Relicensed project as LGPL. Updated standard header. Embed license as resource. * DiscImageChef.Console/DiscImageChef.Console.csproj: * DiscImageChef.Devices/DiscImageChef.Devices.csproj: * DiscImageChef.Helpers/DiscImageChef.Helpers.csproj: * DiscImageChef.Settings/DiscImageChef.Settings.csproj: * DiscImageChef.Decoders/DiscImageChef.Decoders.csproj: * DiscImageChef.Metadata/DiscImageChef.Metadata.csproj: * DiscImageChef.Partitions/DiscImageChef.Partitions.csproj: * DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: * DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj: * DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj: Relicensed as LGPL. Updated standard header. Embed license as resource. * DiscImageChef/DiscImageChef.csproj: * DiscImageChef.Interop/DiscImageChef.Interop.csproj: Updated standard header. Embed license as resource.
2016-07-28 18:13:49 +01:00
// ----------------------------------------------------------------------------
//
// Filename : ProDOS.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Apple ProDOS filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Identifies the Apple ProDOS filesystem and shows information.
//
// --[ 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-02-18 10:02:53 +00:00
// Copyright © 2011-2022 Natalia Portillo
* LICENSE.MIT: * LICENSE.LGPL: Added LICENSE files for LGPL and MIT licenses. * DiscImageChef.Devices/Enums.cs: * DiscImageChef.Partitions/MBR.cs: * DiscImageChef.Partitions/RDB.cs: * DiscImageChef.DiscImages/GDI.cs: * DiscImageChef.Partitions/Sun.cs: * DiscImageChef.DiscImages/VHD.cs: * DiscImageChef.Partitions/GPT.cs: * DiscImageChef.Filesystems/FFS.cs: * DiscImageChef.Filesystems/FAT.cs: * DiscImageChef.Partitions/NeXT.cs: * DiscImageChef.Devices/Command.cs: * DiscImageChef.DiscImages/Nero.cs: * DiscImageChef.Decoders/CD/PMA.cs: * DiscImageChef.Decoders/CD/TOC.cs: * DiscImageChef.Filesystems/BFS.cs: * DiscImageChef.Filesystems/ODS.cs: * DiscImageChef.Helpers/PrintHex.cs: * DiscImageChef.Helpers/Swapping.cs: * DiscImageChef.Decoders/DVD/PRI.cs: * DiscImageChef.Decoders/DVD/DMI.cs: * DiscImageChef.Decoders/DVD/DDS.cs: * DiscImageChef.Decoders/DVD/RMD.cs: * DiscImageChef.Decoders/DVD/UDI.cs: * DiscImageChef.Partitions/Atari.cs: * DiscImageChef.Decoders/DVD/BCA.cs: * DiscImageChef.Filesystems/SysV.cs: * DiscImageChef.Filesystems/HPFS.cs: * DiscImageChef.Filesystems/NTFS.cs: * DiscImageChef.Filesystems/APFS.cs: * DiscImageChef.Decoders/DVD/PFI.cs: * DiscImageChef.Decoders/CD/ATIP.cs: * DiscImageChef.Filesystems/Acorn.cs: * DiscImageChef.DiscImages/CDRWin.cs: * DiscImageChef.DiscImages/CDRDAO.cs: * DiscImageChef.Filesystems/BTRFS.cs: * DiscImageChef.Decoders/Xbox/DMI.cs: * DiscImageChef.Helpers/ArrayFill.cs: * DiscImageChef.Settings/Settings.cs: * DiscImageChef.Filesystems/Opera.cs: * DiscImageChef.Filesystems/extFS.cs: * DiscImageChef.Decoders/DVD/CPRM.cs: * DiscImageChef.Decoders/DVD/ADIP.cs: * DiscImageChef.Decoders/CD/Enums.cs: * DiscImageChef.Decoders/DVD/AACS.cs: * DiscImageChef.Decoders/SCSI/EVPD.cs: * DiscImageChef.Filesystems/ProDOS.cs: * DiscImageChef.Metadata/MediaType.cs: * DiscImageChef.Console/DicConsole.cs: * DiscImageChef.Decoders/DVD/Spare.cs: * DiscImageChef.Filesystems/ext2FS.cs: * DiscImageChef.Decoders/DVD/Enums.cs: * DiscImageChef.Filesystems/Symbian.cs: * DiscImageChef.Decoders/SCSI/Types.cs: * DiscImageChef.Filesystems/UNIXBFS.cs: * DiscImageChef.DiscImages/TeleDisk.cs: * DiscImageChef.Decoders/SCSI/Sense.cs: * DiscImageChef.Decoders/CD/FullTOC.cs: * DiscImageChef.Decoders/Blu-ray/DI.cs: * DiscImageChef.Decoders/ATA/Errors.cs: * DiscImageChef.Filesystems/ISO9660.cs: * DiscImageChef.Filesystems/MinixFS.cs: * DiscImageChef.Devices/Linux/Enums.cs: * DiscImageChef.Filesystems/SolarFS.cs: * DiscImageChef.Filesystems/Structs.cs: * DiscImageChef.DiscImages/Apple2MG.cs: * DiscImageChef.Decoders/SCSI/Modes.cs: * DiscImageChef.Metadata/Dimensions.cs: * DiscImageChef.Partitions/AppleMap.cs: * DiscImageChef.Decoders/Floppy/ISO.cs: * DiscImageChef.Decoders/DVD/Layers.cs: * DiscImageChef.Decoders/CD/Session.cs: * DiscImageChef.Decoders/SCSI/Enums.cs: * DiscImageChef.Filesystems/Nintendo.cs: * DiscImageChef.Helpers/DateHandlers.cs: * DiscImageChef.Filesystems/AmigaDOS.cs: * DiscImageChef.DiscImages/ImageInfo.cs: * DiscImageChef.Checksums/MD5Context.cs: * DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Filesystems/AppleHFS.cs: * DiscImageChef.Filesystems/AppleMFS.cs: * DiscImageChef.Helpers/ArrayIsEmpty.cs: * DiscImageChef.Decoders/Blu-ray/BCA.cs: * DiscImageChef.Decoders/Blu-ray/DDS.cs: * DiscImageChef.Filesystems/PCEngine.cs: * DiscImageChef.Decoders/ATA/Identify.cs: * DiscImageChef.Devices/Linux/Command.cs: * DiscImageChef.Devices/FreeBSD/Enums.cs: * DiscImageChef.Decoders/SCSI/Inquiry.cs: * DiscImageChef.Metadata/DeviceReport.cs: * DiscImageChef.Decoders/Floppy/Amiga.cs: * DiscImageChef.Devices/Linux/Structs.cs: * DiscImageChef.Devices/Windows/Enums.cs: * DiscImageChef.Decoders/DVD/CSS&CPRM.cs: * DiscImageChef.Checksums/SHA1Context.cs: * DiscImageChef.DiscImages/DiskCopy42.cs: * DiscImageChef.Partitions/PartPlugin.cs: * DiscImageChef.CommonTypes/Partition.cs: * DiscImageChef.Decoders/Floppy/Enums.cs: * DiscImageChef.CommonTypes/MediaType.cs: * DiscImageChef.Decoders/Floppy/Apple2.cs: * DiscImageChef.Devices/Windows/Extern.cs: * DiscImageChef.Decoders/SCSI/MMC/CPRM.cs: * DiscImageChef.Helpers/StringHandlers.cs: * DiscImageChef.DiscImages/ImagePlugin.cs: * DiscImageChef.Checksums/CRC64Context.cs: * DiscImageChef.Checksums/CRC32Context.cs: * DiscImageChef.DiscImages/ZZZRawImage.cs: * DiscImageChef.Checksums/CRC16Context.cs: * DiscImageChef.Filesystems/LisaFS/Dir.cs: * DiscImageChef.Decoders/DVD/Cartridge.cs: * DiscImageChef.Decoders/Blu-ray/Spare.cs: * DiscImageChef.Filesystems/Filesystem.cs: * DiscImageChef.Decoders/SCSI/MMC/AACS.cs: * DiscImageChef.Devices/FreeBSD/Extern.cs: * DiscImageChef.Devices/Device/Commands.cs: * DiscImageChef.Checksums/SHA384Context.cs: * DiscImageChef.Devices/FreeBSD/Command.cs: * DiscImageChef.Checksums/SHA512Context.cs: * DiscImageChef.Decoders/SCSI/MMC/Enums.cs: * DiscImageChef.Devices/Windows/Command.cs: * DiscImageChef.Devices/FreeBSD/Structs.cs: * DiscImageChef.Devices/Windows/Structs.cs: * DiscImageChef.Filesystems/LisaFS/Info.cs: * DiscImageChef.Checksums/SHA256Context.cs: * DiscImageChef.Filesystems/LisaFS/File.cs: * DiscImageChef.Filesystems/AppleHFSPlus.cs: * DiscImageChef.Filesystems/LisaFS/Super.cs: * DiscImageChef.Filesystems/LisaFS/Xattr.cs: * DiscImageChef.Checksums/Adler32Context.cs: * DiscImageChef.Decoders/Floppy/System34.cs: * DiscImageChef.Checksums/SpamSumContext.cs: * DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs: * DiscImageChef.Devices/Device/Variables.cs: * DiscImageChef.Filesystems/LisaFS/Consts.cs: * DiscImageChef.Filesystems/LisaFS/LisaFS.cs: * DiscImageChef.Decoders/Floppy/Commodore.cs: * DiscImageChef.Checksums/FletcherContext.cs: * DiscImageChef.Filesystems/LisaFS/Extent.cs: * DiscImageChef.Devices/Device/Destructor.cs: * DiscImageChef.Decoders/Floppy/AppleSony.cs: * DiscImageChef.Filesystems/LisaFS/Structs.cs: * DiscImageChef.Decoders/SCSI/VendorString.cs: * DiscImageChef.Decoders/SCSI/MMC/Features.cs: * DiscImageChef.Devices/Device/Constructor.cs: * DiscImageChef.Checksums/RIPEMD160Context.cs: * DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs: * DiscImageChef.Decoders/Blu-ray/Cartridge.cs: * DiscImageChef.Decoders/Floppy/System3740.cs: * DiscImageChef.Filesystems/LisaFS/Encoding.cs: * DiscImageChef.Decoders/SCSI/ModesEncoders.cs: * DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs: * DiscImageChef.Helpers/BigEndianBitConverter.cs: * DiscImageChef.Decoders/Floppy/Perpendicular.cs: * DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs: * DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs: * DiscImageChef.Devices/Device/ScsiCommands/HP.cs: * DiscImageChef.Devices/Device/AtaCommands/Cfa.cs: * DiscImageChef.Devices/Device/ScsiCommands/NEC.cs: * DiscImageChef.Helpers/EndianAwareBinaryReader.cs: * DiscImageChef.Devices/Device/ScsiCommands/MMC.cs: * DiscImageChef.Devices/Device/AtaCommands/MCPT.cs: * DiscImageChef.Devices/Device/ScsiCommands/SSC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SPC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SMC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SBC.cs: * DiscImageChef.Metadata/Properties/AssemblyInfo.cs: * DiscImageChef.Devices/Device/AtaCommands/Atapi.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata28.cs: * DiscImageChef.Devices/Device/AtaCommands/Smart.cs: * DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata48.cs: * DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs: * DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs: * DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs: * DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs: * DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs: * DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs: * DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs: * DiscImageChef.Devices/Device/ScsiCommands/Certance.cs: * DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs: * DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs: Relicensed as LGPL. Updated standard header. * DiscImageChef/Main.cs: * DiscImageChef/Plugins.cs: * DiscImageChef/Options.cs: * DiscImageChef/Commands/Ls.cs: * DiscImageChef/Core/IBGLog.cs: * DiscImageChef/Core/MHDDLog.cs: * DiscImageChef/AssemblyInfo.cs: * DiscImageChef/Core/Checksum.cs: * DiscImageChef/Commands/Decode.cs: * DiscImageChef/Core/Statistics.cs: * DiscImageChef/Commands/Verify.cs: * DiscImageChef/Commands/Formats.cs: * DiscImageChef/Commands/Entropy.cs: * DiscImageChef/Commands/Compare.cs: * DiscImageChef.Interop/DetectOS.cs: * DiscImageChef/Commands/Analyze.cs: * DiscImageChef/Commands/Commands.cs: * DiscImageChef/Commands/PrintHex.cs: * DiscImageChef/Commands/Checksum.cs: * DiscImageChef/DetectImageFormat.cs: * DiscImageChef/Commands/DumpMedia.cs: * DiscImageChef/Commands/Benchmark.cs: * DiscImageChef/Commands/Configure.cs: * DiscImageChef/Commands/MediaInfo.cs: * DiscImageChef.Interop/PlatformID.cs: * DiscImageChef/Commands/MediaScan.cs: * DiscImageChef/Commands/Statistics.cs: * DiscImageChef/Commands/DeviceInfo.cs: * DiscImageChef.Checksums/ReedSolomon.cs: * DiscImageChef/Commands/DeviceReport.cs: * DiscImageChef/Commands/ExtractFiles.cs: * DiscImageChef.Checksums/CDChecksums.cs: * DiscImageChef/Commands/CreateSidecar.cs: Updated standard header. * DiscImageChef.Checksums/DiscImageChef.Checksums.csproj: Relicensed project as LGPL. Updated standard header. Embed license as resource. * DiscImageChef.Console/DiscImageChef.Console.csproj: * DiscImageChef.Devices/DiscImageChef.Devices.csproj: * DiscImageChef.Helpers/DiscImageChef.Helpers.csproj: * DiscImageChef.Settings/DiscImageChef.Settings.csproj: * DiscImageChef.Decoders/DiscImageChef.Decoders.csproj: * DiscImageChef.Metadata/DiscImageChef.Metadata.csproj: * DiscImageChef.Partitions/DiscImageChef.Partitions.csproj: * DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: * DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj: * DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj: Relicensed as LGPL. Updated standard header. Embed license as resource. * DiscImageChef/DiscImageChef.csproj: * DiscImageChef.Interop/DiscImageChef.Interop.csproj: Updated standard header. Embed license as resource.
2016-07-28 18:13:49 +01:00
// ****************************************************************************/
2022-03-07 07:36:44 +00:00
// ReSharper disable NotAccessedField.Local
using System;
2020-07-20 07:47:12 +01:00
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
2020-02-29 18:03:35 +00:00
using Claunia.Encoding;
2017-12-21 14:30:38 +00:00
using Schemas;
using Encoding = System.Text.Encoding;
namespace Aaru.Filesystems;
2022-03-06 13:29:38 +00:00
// Information from Apple ProDOS 8 Technical Reference
/// <inheritdoc />
/// <summary>Implements detection of Apple ProDOS filesystem</summary>
[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")]
public sealed class ProDOSPlugin : IFilesystem
{
2022-03-06 13:29:38 +00:00
const byte EMPTY_STORAGE_TYPE = 0x00;
/// <summary>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</summary>
const byte SAPLING_FILE_TYPE = 0x02;
/// <summary>A file that occupies between 257 and 32768 blocks</summary>
const byte TREE_FILE_TYPE = 0x03;
const byte PASCAL_AREA_TYPE = 0x04;
const byte SUBDIRECTORY_TYPE = 0x0D;
const byte SUBDIRECTORY_HEADER_TYPE = 0x0E;
const byte ROOT_DIRECTORY_TYPE = 0x0F;
const byte VERSION1 = 0x00;
const uint YEAR_MASK = 0xFE000000;
const uint MONTH_MASK = 0x1E00000;
const uint DAY_MASK = 0x1F0000;
const uint HOUR_MASK = 0x1F00;
const uint MINUTE_MASK = 0x3F;
const byte DESTROY_ATTRIBUTE = 0x80;
const byte RENAME_ATTRIBUTE = 0x40;
const byte BACKUP_ATTRIBUTE = 0x20;
const byte WRITE_ATTRIBUTE = 0x02;
const byte READ_ATTRIBUTE = 0x01;
const byte RESERVED_ATTRIBUTE_MASK = 0x1C;
const byte STORAGE_TYPE_MASK = 0xF0;
const byte NAME_LENGTH_MASK = 0x0F;
const byte ENTRY_LENGTH = 0x27;
const byte ENTRIES_PER_BLOCK = 0x0D;
/// <inheritdoc />
public FileSystemType XmlFsType { get; private set; }
/// <inheritdoc />
public Encoding Encoding { get; private set; }
/// <inheritdoc />
public string Name => "Apple ProDOS filesystem";
/// <inheritdoc />
public Guid Id => new("43874265-7B8A-4739-BCF7-07F80D5932BF");
/// <inheritdoc />
2022-03-06 13:29:38 +00:00
public string Author => "Natalia Portillo";
/// <inheritdoc />
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
2022-03-06 13:29:38 +00:00
if(partition.Length < 3)
return false;
uint multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
2022-03-06 13:29:38 +00:00
// Blocks 0 and 1 are boot code
ErrorNumber errno = imagePlugin.ReadSectors((2 * multiplier) + partition.Start, multiplier,
2022-03-06 13:29:38 +00:00
out byte[] rootDirectoryKeyBlock);
2022-03-17 23:54:41 +00:00
if(errno != ErrorNumber.NoError)
return false;
bool apmFromHddOnCd = false;
2022-03-16 11:47:00 +00:00
if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048)
2022-03-06 13:29:38 +00:00
{
errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp);
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(errno != ErrorNumber.NoError)
2020-02-29 18:03:35 +00:00
return false;
2022-03-06 13:29:38 +00:00
foreach(int offset in new[]
{
0, 0x200, 0x400, 0x600, 0x800, 0xA00
}.Where(offset => tmp.Length > offset + 0x200 && 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;
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
break;
}
}
ushort prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0);
2022-03-06 13:29:38 +00:00
AaruConsole.DebugWriteLine("ProDOS plugin", "prePointer = {0}", prePointer);
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(prePointer != 0)
return false;
byte storageType = (byte)((rootDirectoryKeyBlock[0x04] & STORAGE_TYPE_MASK) >> 4);
2022-03-06 13:29:38 +00:00
AaruConsole.DebugWriteLine("ProDOS plugin", "storage_type = {0}", storageType);
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(storageType != ROOT_DIRECTORY_TYPE)
return false;
2022-03-06 13:29:38 +00:00
byte entryLength = rootDirectoryKeyBlock[0x23];
AaruConsole.DebugWriteLine("ProDOS plugin", "entry_length = {0}", entryLength);
2022-03-06 13:29:38 +00:00
if(entryLength != ENTRY_LENGTH)
return false;
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
byte entriesPerBlock = rootDirectoryKeyBlock[0x24];
AaruConsole.DebugWriteLine("ProDOS plugin", "entries_per_block = {0}", entriesPerBlock);
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(entriesPerBlock != ENTRIES_PER_BLOCK)
return false;
2017-12-19 20:33:03 +00:00
ushort bitMapPointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27);
2022-03-06 13:29:38 +00:00
AaruConsole.DebugWriteLine("ProDOS plugin", "bit_map_pointer = {0}", bitMapPointer);
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(bitMapPointer > partition.End)
return false;
ushort totalBlocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29);
2022-03-06 13:29:38 +00:00
if(apmFromHddOnCd)
totalBlocks /= 4;
2022-03-06 13:29:38 +00:00
AaruConsole.DebugWriteLine("ProDOS plugin", "{0} <= ({1} - {2} + 1)? {3}", totalBlocks, partition.End,
partition.Start, totalBlocks <= partition.End - partition.Start + 1);
2022-03-06 13:29:38 +00:00
return totalBlocks <= partition.End - partition.Start + 1;
}
2022-03-06 13:29:38 +00:00
/// <inheritdoc />
2022-03-07 07:36:44 +00:00
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
2022-03-06 13:29:38 +00:00
{
Encoding = encoding ?? new Apple2c();
information = "";
var sbInformation = new StringBuilder();
uint multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
2022-03-06 13:29:38 +00:00
// Blocks 0 and 1 are boot code
ErrorNumber errno = imagePlugin.ReadSectors((2 * multiplier) + partition.Start, multiplier,
2022-03-06 13:29:38 +00:00
out byte[] rootDirectoryKeyBlockBytes);
2022-03-06 13:29:38 +00:00
if(errno != ErrorNumber.NoError)
return;
2020-02-29 18:03:35 +00:00
bool apmFromHddOnCd = false;
2022-03-16 11:47:00 +00:00
if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048)
2022-03-06 13:29:38 +00:00
{
errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp);
2022-03-06 13:29:38 +00:00
if(errno != ErrorNumber.NoError)
return;
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
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))
{
2022-03-06 13:29:38 +00:00
Array.Copy(tmp, offset, rootDirectoryKeyBlockBytes, 0, 0x200);
apmFromHddOnCd = true;
break;
2020-02-29 18:03:35 +00:00
}
2022-03-06 13:29:38 +00:00
}
2022-03-06 13:29:38 +00:00
var rootDirectoryKeyBlock = new RootDirectoryKeyBlock
{
header = new RootDirectoryHeader(),
zero = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x00),
next_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x02)
};
2022-03-07 07:36:44 +00:00
rootDirectoryKeyBlock.header.storage_type = (byte)((rootDirectoryKeyBlockBytes[0x04] & STORAGE_TYPE_MASK) >> 4);
2022-03-06 13:29:38 +00:00
rootDirectoryKeyBlock.header.name_length = (byte)(rootDirectoryKeyBlockBytes[0x04] & NAME_LENGTH_MASK);
byte[] temporal = new byte[rootDirectoryKeyBlock.header.name_length];
2022-03-06 13:29:38 +00:00
Array.Copy(rootDirectoryKeyBlockBytes, 0x05, temporal, 0, rootDirectoryKeyBlock.header.name_length);
rootDirectoryKeyBlock.header.volume_name = Encoding.GetString(temporal);
rootDirectoryKeyBlock.header.reserved = BitConverter.ToUInt64(rootDirectoryKeyBlockBytes, 0x14);
ushort tempTimestampLeft = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1C);
ushort tempTimestampRight = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1E);
2022-03-06 13:29:38 +00:00
bool dateCorrect;
2022-03-06 13:29:38 +00:00
try
{
uint tempTimestamp = (uint)((tempTimestampLeft << 16) + tempTimestampRight);
int year = (int)((tempTimestamp & YEAR_MASK) >> 25);
int month = (int)((tempTimestamp & MONTH_MASK) >> 21);
int day = (int)((tempTimestamp & DAY_MASK) >> 16);
int hour = (int)((tempTimestamp & HOUR_MASK) >> 8);
int minute = (int)(tempTimestamp & MINUTE_MASK);
2022-03-06 13:29:38 +00:00
year += 1900;
if(year < 1940)
year += 100;
AaruConsole.DebugWriteLine("ProDOS plugin", "temp_timestamp_left = 0x{0:X4}", tempTimestampLeft);
AaruConsole.DebugWriteLine("ProDOS plugin", "temp_timestamp_right = 0x{0:X4}", tempTimestampRight);
AaruConsole.DebugWriteLine("ProDOS plugin", "temp_timestamp = 0x{0:X8}", tempTimestamp);
AaruConsole.DebugWriteLine("ProDOS plugin",
"Datetime field year {0}, month {1}, day {2}, hour {3}, minute {4}.", year,
month, day, hour, minute);
rootDirectoryKeyBlock.header.creation_time = new DateTime(year, month, day, hour, minute, 0);
dateCorrect = true;
}
catch(ArgumentOutOfRangeException)
{
dateCorrect = false;
}
2022-03-06 13:29:38 +00:00
rootDirectoryKeyBlock.header.version = rootDirectoryKeyBlockBytes[0x20];
rootDirectoryKeyBlock.header.min_version = rootDirectoryKeyBlockBytes[0x21];
rootDirectoryKeyBlock.header.access = rootDirectoryKeyBlockBytes[0x22];
rootDirectoryKeyBlock.header.entry_length = rootDirectoryKeyBlockBytes[0x23];
rootDirectoryKeyBlock.header.entries_per_block = rootDirectoryKeyBlockBytes[0x24];
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
rootDirectoryKeyBlock.header.file_count = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x25);
rootDirectoryKeyBlock.header.bit_map_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x27);
rootDirectoryKeyBlock.header.total_blocks = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x29);
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(apmFromHddOnCd)
2022-03-07 07:36:44 +00:00
sbInformation.AppendLine("ProDOS uses 512 bytes/sector while devices uses 2048 bytes/sector.").AppendLine();
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
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");
}
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(rootDirectoryKeyBlock.header.version == VERSION1)
sbInformation.AppendLine("ProDOS version 1 used to create this volume.");
else
sbInformation.AppendFormat("Unknown ProDOS version with field {0} used to create this volume.",
rootDirectoryKeyBlock.header.version).AppendLine();
if(rootDirectoryKeyBlock.header.min_version == VERSION1)
sbInformation.AppendLine("ProDOS version 1 at least required for reading this volume.");
else
sbInformation.
AppendFormat("Unknown ProDOS version with field {0} is at least required for reading this volume.",
rootDirectoryKeyBlock.header.min_version).AppendLine();
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
sbInformation.AppendFormat("Volume name is {0}", rootDirectoryKeyBlock.header.volume_name).AppendLine();
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(dateCorrect)
sbInformation.AppendFormat("Volume created on {0}", rootDirectoryKeyBlock.header.creation_time).
2020-02-29 18:03:35 +00:00
AppendLine();
2022-03-06 13:29:38 +00:00
sbInformation.AppendFormat("{0} bytes per directory entry", rootDirectoryKeyBlock.header.entry_length).
AppendLine();
2020-02-29 18:03:35 +00:00
2022-03-07 07:36:44 +00:00
sbInformation.AppendFormat("{0} entries per directory block", rootDirectoryKeyBlock.header.entries_per_block).
2022-03-06 13:29:38 +00:00
AppendLine();
2020-02-29 18:03:35 +00:00
2022-03-07 07:36:44 +00:00
sbInformation.AppendFormat("{0} files in root directory", rootDirectoryKeyBlock.header.file_count).AppendLine();
2022-03-06 13:29:38 +00:00
sbInformation.AppendFormat("{0} blocks in volume", rootDirectoryKeyBlock.header.total_blocks).AppendLine();
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
sbInformation.AppendFormat("Bitmap starts at block {0}", rootDirectoryKeyBlock.header.bit_map_pointer).
AppendLine();
2022-03-06 13:29:38 +00:00
if((rootDirectoryKeyBlock.header.access & READ_ATTRIBUTE) == READ_ATTRIBUTE)
sbInformation.AppendLine("Volume can be read");
2022-03-06 13:29:38 +00:00
if((rootDirectoryKeyBlock.header.access & WRITE_ATTRIBUTE) == WRITE_ATTRIBUTE)
sbInformation.AppendLine("Volume can be written");
2022-03-06 13:29:38 +00:00
if((rootDirectoryKeyBlock.header.access & RENAME_ATTRIBUTE) == RENAME_ATTRIBUTE)
sbInformation.AppendLine("Volume can be renamed");
2018-06-20 22:22:21 +01:00
2022-03-06 13:29:38 +00:00
if((rootDirectoryKeyBlock.header.access & DESTROY_ATTRIBUTE) == DESTROY_ATTRIBUTE)
sbInformation.AppendLine("Volume can be destroyed");
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if((rootDirectoryKeyBlock.header.access & BACKUP_ATTRIBUTE) == BACKUP_ATTRIBUTE)
sbInformation.AppendLine("Volume must be backed up");
2022-03-06 13:29:38 +00:00
if((rootDirectoryKeyBlock.header.access & RESERVED_ATTRIBUTE_MASK) != 0)
AaruConsole.DebugWriteLine("ProDOS plugin", "Reserved attributes are set: {0:X2}",
rootDirectoryKeyBlock.header.access);
2022-03-06 13:29:38 +00:00
information = sbInformation.ToString();
2022-03-06 13:29:38 +00:00
XmlFsType = new FileSystemType
{
2022-03-06 13:29:38 +00:00
VolumeName = rootDirectoryKeyBlock.header.volume_name,
Files = rootDirectoryKeyBlock.header.file_count,
FilesSpecified = true,
Clusters = rootDirectoryKeyBlock.header.total_blocks,
Type = "ProDOS"
};
2022-03-06 13:29:38 +00:00
XmlFsType.ClusterSize = (uint)((partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize /
XmlFsType.Clusters);
2022-03-06 13:29:38 +00:00
if(!dateCorrect)
return;
2022-03-06 13:29:38 +00:00
XmlFsType.CreationDate = rootDirectoryKeyBlock.header.creation_time;
XmlFsType.CreationDateSpecified = true;
}
2022-03-06 13:29:38 +00:00
/// <summary>ProDOS directory entry, decoded structure</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct Entry
{
/// <summary>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</summary>
public byte name_length;
/// <summary>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</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
/// </summary>
public ushort key_pointer;
/// <summary>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</summary>
public uint EOF;
/// <summary>File creation datetime Offset 0x18, 4 bytes</summary>
public DateTime creation_time;
/// <summary>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</summary>
public byte min_version;
/// <summary>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</summary>
public ushort aux_type;
/// <summary>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</summary>
public ushort header_pointer;
}
2022-03-06 13:29:38 +00:00
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct RootDirectoryHeader
{
/// <summary>Constant 0x0F Offset 0x04, mask 0xF0</summary>
public byte storage_type;
/// <summary>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</summary>
public string volume_name;
/// <summary>Reserved for future expansion Offset 0x14, 8 bytes</summary>
public ulong reserved;
/// <summary>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</summary>
public byte version;
/// <summary>Reserved for future use Offset 0x21, 1 byte</summary>
public byte min_version;
/// <summary>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</summary>
public byte entry_length;
/// <summary>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</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
/// </summary>
public ushort bit_map_pointer;
/// <summary>Total number of blocks in the volume Offset 0x29, 2 bytes</summary>
public ushort total_blocks;
}
2022-03-06 13:29:38 +00:00
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct DirectoryHeader
{
/// <summary>Constant 0x0E Offset 0x04, mask 0xF0</summary>
public byte storage_type;
/// <summary>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</summary>
public string directory_name;
/// <summary>Reserved for future expansion Offset 0x14, 8 bytes</summary>
public ulong reserved;
/// <summary>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</summary>
public byte version;
/// <summary>Reserved for future use Offset 0x21, 1 byte</summary>
public byte min_version;
/// <summary>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</summary>
public byte entry_length;
/// <summary>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</summary>
public ushort file_count;
/// <summary>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</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</summary>
public byte parent_entry_length;
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct DirectoryKeyBlock
{
/// <summary>Always 0 Offset 0x00, 2 bytes</summary>
public ushort zero;
/// <summary>Pointer to next directory block, 0 if last Offset 0x02, 2 bytes</summary>
public ushort next_pointer;
/// <summary>Directory header Offset 0x04, 39 bytes</summary>
public DirectoryHeader header;
/// <summary>Directory entries Offset 0x2F, 39 bytes each, 12 entries</summary>
public Entry[] entries;
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct RootDirectoryKeyBlock
{
/// <summary>Always 0 Offset 0x00, 2 bytes</summary>
public ushort zero;
/// <summary>Pointer to next directory block, 0 if last Offset 0x02, 2 bytes</summary>
public ushort next_pointer;
/// <summary>Directory header Offset 0x04, 39 bytes</summary>
public RootDirectoryHeader header;
/// <summary>Directory entries Offset 0x2F, 39 bytes each, 12 entries</summary>
public Entry[] entries;
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct DirectoryBlock
{
/// <summary>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</summary>
public ushort next_pointer;
/// <summary>Directory entries Offset 0x2F, 39 bytes each, 13 entries</summary>
public Entry[] entries;
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct IndexBlock
{
/// <summary>Up to 256 pointers to blocks, 0 to indicate the block is sparsed (non-allocated)</summary>
public ushort[] block_pointer;
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct MasterIndexBlock
{
/// <summary>Up to 128 pointers to index blocks</summary>
public ushort[] index_block_pointer;
}
2017-12-19 20:33:03 +00:00
}