Class DosFormatDisk

    • Field Detail

      • TRACK_LOCATION_INDEX

        public static final int TRACK_LOCATION_INDEX
        Indicates the index of the track in the location array.
        See Also:
        Constant Field Values
      • SECTOR_LOCATION_INDEX

        public static final int SECTOR_LOCATION_INDEX
        Indicates the index of the sector in the location array.
        See Also:
        Constant Field Values
      • CATALOG_TRACK

        public static final int CATALOG_TRACK
        The standard DOS 3.3 catalog track.
        See Also:
        Constant Field Values
      • VTOC_SECTOR

        public static final int VTOC_SECTOR
        The standard VTOC sector.
        See Also:
        Constant Field Values
      • TRACK_SECTOR_PAIRS

        public static final int TRACK_SECTOR_PAIRS
        The standard track/sector pairs in a track/sector list.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DosFormatDisk

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

      • create

        public static DosFormatDisk[] create​(java.lang.String filename,
                                             ImageOrder imageOrder)
        Create a DosFormatDisk. All DOS disk images are expected to be 140K in size.
      • 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 been implemented to something specific about the disk.
      • getFreeSpace

        public int getFreeSpace()
        Compute the amount of freespace available on the disk. This algorithm completely ignores tracks and sectors by running through the entire bitmap stored on the VTOC.
        Specified by:
        getFreeSpace in class FormattedDisk
        See Also:
        FormattedDisk.getFreeSpace()
      • getFreeSectors

        public int getFreeSectors()
        Compute the number of free sectors available on the disk.
      • getUsedSectors

        public int getUsedSectors()
        Compute the number of used sectors on the disk.
      • getTotalSectors

        public int getTotalSectors()
        Compute the total number of sectors available on the disk.
      • getDiskName

        public java.lang.String getDiskName()
        Return the DOS disk name. Basically, the DISK VOLUME #xxx that a CATALOG command would show. Note that Java bytes are signed, so a little mojo is in order.
        Specified by:
        getDiskName in class FormattedDisk
        See Also:
        FormattedDisk.getDiskName()
      • readVtoc

        public byte[] readVtoc()
        Return the VTOC (Volume Table Of Contents).
      • writeVtoc

        public void writeVtoc​(byte[] vtoc)
        Save the VTOC (Volume Table Of Contents) to disk.
      • getTracks

        public int getTracks()
        Get the number of tracks on this disk.
      • getSectors

        public int getSectors()
        Get the number of sectors on this disk.
      • 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
      • 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
      • freeSectors

        protected void freeSectors​(DosFileEntry dosFileEntry)
        Free sectors used by a DosFileEntry.
      • format

        protected void format​(int firstCatalogSector,
                              int tracksPerDisk,
                              int sectorsPerTrack)
        Format the disk as DOS 3.3 given the dynamic parameters. (Used for UniDOS and OzDOS.)
      • isSectorFree

        public boolean isSectorFree​(int track,
                                    int sector,
                                    byte[] vtoc)
        Indicates if a specific track/sector is free.
      • isSectorUsed

        public boolean isSectorUsed​(int track,
                                    int sector,
                                    byte[] vtoc)
        Indicates if a specific track/sector is used.
      • setSectorFree

        public void setSectorFree​(int track,
                                  int sector,
                                  byte[] vtoc)
        Sets the track/sector indicator to free.
      • setSectorUsed

        public void setSectorUsed​(int track,
                                  int sector,
                                  byte[] vtoc)
        Sets the track/sector indicator to used.
      • getFreeMapByte

        protected int getFreeMapByte​(int track,
                                     int sector)
        Compute the VTOC byte for the T/S map.
      • getFreeMapBit

        protected int getFreeMapBit​(int sector)
        Compute the VTOC bit for the T/S map.
      • checkRange

        protected void checkRange​(int track,
                                  int sector)
        Validate track/sector range. This just validates the maximum values allowable for track and sector.
      • 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. DOS 3.3 pretty much allows anything - so it is cut to 30 characters and trimmed (trailing whitespace may cause confusion).
        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
      • 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. For DOS, only the Binary type needs an address.
        Specified by:
        needsAddress in class FormattedDisk
      • 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 DOS 3.3 format but the underlying order can change.
        Specified by:
        changeImageOrder in class FormattedDisk
        See Also:
        ImageOrder
      • 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