Class ProdosFormatDisk

  • All Implemented Interfaces:
    DirectoryEntry

    public class ProdosFormatDisk
    extends FormattedDisk
    Manages a disk that is in the ProDOS format.

    Date created: Oct 3, 2002 11:45:25 PM

    • Constructor Detail

      • ProdosFormatDisk

        public ProdosFormatDisk​(java.lang.String filename,
                                ImageOrder imageOrder)
        Constructor for ProdosFormatDisk.
        Parameters:
        filename -
    • Method Detail

      • create

        public static ProdosFormatDisk[] create​(java.lang.String filename,
                                                java.lang.String diskName,
                                                ImageOrder imageOrder)
        Create a ProdosFormatDisk.
      • getFiles

        protected java.util.List<FileEntry> getFiles​(int blockNumber)
                                              throws DiskException
        Build a list of files, starting in the given block number. This works for the master as well as the subdirectories.
        Throws:
        DiskException
      • getFreeBlocks

        public int getFreeBlocks()
        Return the number of free blocks on the disk.
      • getUsedBlocks

        public int getUsedBlocks()
        Return the number of used blocks on the disk.
      • canCreateDirectories

        public boolean canCreateDirectories()
        Identify if additional directories can be created. This may indicate that directories are not available to this operating system or simply that the disk image is "locked" to writing.
      • canCreateFile

        public boolean canCreateFile()
        Indicates if this disk image can create a file. If not, the reason may be as simple as it has not beem implemented to something specific about the disk.
      • setDiskName

        public void setDiskName​(java.lang.String volumeName)
        Set the name of the disk (volume name).
        Overrides:
        setDiskName in class FormattedDisk
      • getBitmapDimensions

        public int[] getBitmapDimensions()
        Get suggested dimensions for display of bitmap. There is no suggestion for a ProDOS volume - it is just a series of blocks.
        Specified by:
        getBitmapDimensions in class FormattedDisk
      • getBitmapLabels

        public java.lang.String[] getBitmapLabels()
        Get the labels to use in the bitmap.
        Specified by:
        getBitmapLabels in class FormattedDisk
      • supportsDeletedFiles

        public boolean supportsDeletedFiles()
        Indicates if this disk format supports "deleted" files.
        Specified by:
        supportsDeletedFiles in class FormattedDisk
      • canReadFileData

        public boolean canReadFileData()
        Indicates if this disk image can read data from a file.
        Specified by:
        canReadFileData in class FormattedDisk
      • canWriteFileData

        public boolean canWriteFileData()
        Indicates if this disk image can write data to a file.
        Specified by:
        canWriteFileData in class FormattedDisk
      • canDeleteFile

        public boolean canDeleteFile()
        Indicates if this disk image can delete a file.
        Specified by:
        canDeleteFile in class FormattedDisk
      • getFileData

        public byte[] getFileData​(FileEntry fileEntry)
        Get the data associated with the specified FileEntry. Note that this could return a 16MB file! Sparse files are not treated specially.
        Specified by:
        getFileData in class FormattedDisk
        See Also:
        FileEntry.getFileData()
      • freeBlocks

        protected void freeBlocks​(ProdosFileEntry prodosFileEntry)
        Free blocks used by a ProdosFileEntry.
      • getIndexBlockData

        protected int getIndexBlockData​(byte[] fileData,
                                        byte[] indexBlock,
                                        int offset)
        Read file data from the given index block. Note that block number 0 is an unused block.
      • setFileData

        protected void setFileData​(ProdosFileEntry fileEntry,
                                   byte[] fileData)
                            throws DiskFullException
        Set the data associated with the specified ProdosFileEntry into sectors on the disk. Automatically grows the filesystem structures from seedling to sapling to tree.
        Throws:
        DiskFullException
      • setFileData

        protected void setFileData​(ProdosFileEntry fileEntry,
                                   byte[] dataFork,
                                   byte[] resourceFork)
                            throws DiskFullException
        Set the data associated with the specified ProdosFileEntry into sectors on the disk. Automatically grows the filesystem structures from seedling to sapling to tree.
        Throws:
        DiskFullException
      • setGEOSFileData

        protected void setGEOSFileData​(ProdosFileEntry fileEntry,
                                       byte[] fileData)
                                throws DiskFullException
        Set the data associated with the specified ProdosFileEntry into sectors on the disk. Take GEOS file structures into account.
        Throws:
        DiskFullException
      • readVolumeBitMap

        public byte[] readVolumeBitMap()
        Read the Volume Bit Map.
      • writeVolumeBitMap

        public void writeVolumeBitMap​(byte[] data)
        Write the Volume Bit Map.
      • isBlockFree

        public boolean isBlockFree​(byte[] data,
                                   int blockNumber)
        Determine if the specified block is free.
      • setBlockFree

        public void setBlockFree​(byte[] data,
                                 int blockNumber)
        Set if the specified block is free.
      • isBlockUsed

        public boolean isBlockUsed​(byte[] data,
                                   int blockNumber)
        Determine if the specified block is used.
      • setBlockUsed

        public void setBlockUsed​(byte[] data,
                                 int blockNumber)
        Set if the specified block is free.
      • getLogicalDiskNumber

        public int getLogicalDiskNumber()
        Returns the logical disk number. Returns a 0 to indicate no numbering.
        Specified by:
        getLogicalDiskNumber in class FormattedDisk
      • getSuggestedFilename

        public java.lang.String getSuggestedFilename​(java.lang.String filename)
        Returns a valid filename for the given filename. ProDOS filenames have a maximum length of 15 characters, must start with a character and may contain characters (A-Z), digits (0-9), or the period (.).
        Specified by:
        getSuggestedFilename in class FormattedDisk
      • getSuggestedFiletype

        public java.lang.String getSuggestedFiletype​(java.lang.String filename)
        Returns a valid filetype for the given filename. The most simple format will just assume a filetype of binary. This method is available for the interface to make an intelligent first guess as to the filetype.
        Specified by:
        getSuggestedFiletype in class FormattedDisk
      • getFiletype

        public static java.lang.String getFiletype​(int filetype)
        Return the filetype of this file. This will be three characters, according to ProDOS - a "$xx" if unknown.
      • getFiletype

        public byte getFiletype​(java.lang.String filetype)
        Get the numerical filetype.
      • fileTypeNeedsAddress

        public static boolean fileTypeNeedsAddress​(java.lang.String filetype)
        Utility method to indicate if this file type needs an address.
      • getFiletypes

        public java.lang.String[] getFiletypes()
        Returns a list of possible file types. Since the filetype is specific to each operating system, a simple String is used.
        Specified by:
        getFiletypes in class FormattedDisk
      • needsAddress

        public boolean needsAddress​(java.lang.String filetype)
        Indicates if this filetype requires an address component.
        Specified by:
        needsAddress in class FormattedDisk
      • canCompile

        public boolean canCompile​(java.lang.String filetype)
        Indicates if this filetype can be compiled.
      • supportsDiskMap

        public boolean supportsDiskMap()
        Indicates if this FormattedDisk supports a disk map.
        Overrides:
        supportsDiskMap in class FormattedDisk
      • changeImageOrder

        public void changeImageOrder​(ImageOrder imageOrder)
        Change to a different ImageOrder. Remains in ProDOS format but the underlying order can change.
        Specified by:
        changeImageOrder in class FormattedDisk
        See Also:
        ImageOrder
      • setFileData

        public void setFileData​(FileEntry fileEntry,
                                byte[] fileData)
                         throws DiskFullException
        Writes the raw bytes into the file. This bypasses any special formatting of the data (such as prepending the data with a length and/or an address). Typically, the FileEntry.setFileData method should be used.
        Specified by:
        setFileData in class FormattedDisk
        Throws:
        DiskFullException
      • fromProdosFiletype

        public java.lang.String fromProdosFiletype​(java.lang.String prodosFiletype)
        Provides conversation from a given ProDOS file type since as it is common across many archiving tools.
        Specified by:
        fromProdosFiletype in class FormattedDisk
      • toProdosFiletype

        public java.lang.String toProdosFiletype​(java.lang.String nativeFiletype)
        Provides conversation to a given ProDOS file type since as it is common across many archiving tools.
        Specified by:
        toProdosFiletype in class FormattedDisk