Class FormattedDisk

    • Field Detail

      • FILE_DISPLAY_STANDARD

        public static final int FILE_DISPLAY_STANDARD
        This inner class represents the column header information used in the directory display. Note that this needs to be synchronized with the appropriate FileEntry objects.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FormattedDisk

        public FormattedDisk​(java.lang.String filename,
                             ImageOrder imageOrder)
        Constructor for FormattedDisk.
    • Method Detail

      • getDiskName

        public abstract java.lang.String getDiskName()
        Return the name of the disk. Not the physical file name, but "DISK VOLUME #xxx" (DOS 3.3) or "/MY.DISK" (ProDOS).
      • getDirname

        public java.lang.String getDirname()
        Return a name for this directory.
        Specified by:
        getDirname in interface DirectoryEntry
      • setDiskName

        public void setDiskName​(java.lang.String volumeName)
        Set the name of the disk to volumeName.
      • getFormat

        public abstract java.lang.String getFormat()
        Identify the operating system format of this disk.
      • getFreeSpace

        public abstract int getFreeSpace()
        Return the amount of free space in bytes.
      • getUsedSpace

        public abstract int getUsedSpace()
        Return the amount of used space in bytes.
      • getBitmapDimensions

        public abstract int[] getBitmapDimensions()
        Get suggested dimensions for display of bitmap. Typically, this will be only used for 5.25" floppies. This can return null if there is no suggestion.
      • getBitmapLength

        public abstract int getBitmapLength()
        Get the length of the bitmap.
      • getBitmapLabels

        public abstract java.lang.String[] getBitmapLabels()
        Get the labels to use in the bitmap. Note that this should, at a minimum, return an array of String[1] unless the bitmap has not been implemented.
      • getDiskInformation

        public java.util.List<FormattedDisk.DiskInformation> getDiskInformation()
        Get disk information. This is intended to be pretty generic - each disk format can build this as appropriate. Each subclass should override this method and add its own detail.
      • getFileColumnHeaders

        public java.util.List<FormattedDisk.FileColumnHeader> getFileColumnHeaders​(int displayMode)
        Get the standard file column header information. This default implementation is intended only for standard mode.
      • supportsDeletedFiles

        public abstract boolean supportsDeletedFiles()
        Indicates if this disk format supports "deleted" files. Not to be confused with being able to delete a file, this indicates that deleted entries remain in the filesystem after the file has been deleted. There are some filesystems that "compress" the file out of the structure by completely removing the entry instead of marking it deleted (like Apple Pascal).
      • canReadFileData

        public abstract boolean canReadFileData()
        Indicates if this disk image can read data from a file. If not, the reason may be as simple as it has not beem implemented to something specific about the disk.
      • canWriteFileData

        public abstract boolean canWriteFileData()
        Indicates if this disk image can write data to a file. If not, the reason may be as simple as it has not beem implemented to something specific about the disk (such as read-only image).
      • canHaveDirectories

        public abstract boolean canHaveDirectories()
        Identify if this disk format is capable of having directories.
      • canDeleteFile

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

        public abstract byte[] getFileData​(FileEntry fileEntry)
        Get the data associated with the specified FileEntry. This is just the raw data. Use the FileEntry itself to read data appropriately! For instance, DOS "B" (binary) files store length and address as part of the file itself, but it is not treated as file data.
        See Also:
        FileEntry.getFileData()
      • getFile

        public FileEntry getFile​(java.lang.String filename)
                          throws DiskException
        Locate a specific file by filename. Returns a null if specific filename is not located.
        Throws:
        DiskException
      • getFile

        protected FileEntry getFile​(java.util.List<FileEntry> files,
                                    java.lang.String filename)
                             throws DiskException
        Recursive routine to locate a specific file by filename. Note that in the instance of a system with directories (ie, ProDOS), this really returns the first file with the given filename.
        Throws:
        DiskException
      • format

        public abstract void format()
        Format the disk. Make sure that this is what is intended - there is no backing out!
      • writeBootCode

        protected void writeBootCode()
        Write the AppleCommander boot code to track 0 sector 0 of the disk. This will work for a floppy, but may cause problems for other devices.
      • getLogicalDiskNumber

        public abstract int getLogicalDiskNumber()
        Returns the logical disk number. This can be used to identify between disks when a format supports multiple logical volumes. If a value of 0 is returned, there is not multiple logical volumes to distinguish.
      • getSuggestedFilename

        public abstract java.lang.String getSuggestedFilename​(java.lang.String filename)
        Returns a valid filename for the given filename. This does not necessarily guarantee a unique filename - just validity of the filename.
      • getSuggestedFiletype

        public abstract 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.
      • getFiletypes

        public abstract 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.
      • needsAddress

        public abstract boolean needsAddress​(java.lang.String filetype)
        Indicates if this filetype requires an address component.
      • getFormattedDisk

        public FormattedDisk getFormattedDisk()
        Get the FormattedDisk associated with this DirectoryEntry. This is useful to interfaces that need to retrieve the associated disk.
        Specified by:
        getFormattedDisk in interface DirectoryEntry
      • resizeDiskImage

        public void resizeDiskImage()
        Resize the disk image to be its full size. Only invoke this method if a size does not match exception is thrown.
      • supportsDiskMap

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

        public abstract void changeImageOrder​(ImageOrder imageOrder)
        Change the physical ordering of the disk. This must be implemented by all subclasses. See AppleUtil for common utility methods. (It is assumed that a disk needs to be copied in the appropriate order - i.e., by track and sector for a DOS type disk or by blocks in a ProDOS type disk.)
      • setFileData

        public abstract 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.
        Throws:
        DiskFullException
      • getDiskGeometry

        public abstract DiskGeometry getDiskGeometry()
        Gives an indication on how this disk's geometry should be handled.
      • fromProdosFiletype

        public abstract 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.
      • toProdosFiletype

        public abstract 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.