java.lang.Object
com.webcodepro.applecommander.storage.Disk
Direct Known Subclasses:
FormattedDisk

public class Disk extends Object
Abstract representation of an Apple2 disk (floppy, 800k, hard disk).

Date created: Oct 3, 2002 10:59:47 PM

  • Field Details

  • Constructor Details

    • Disk

      protected Disk(String filename, ImageOrder imageOrder)
      Construct a Disk with the given byte array.
    • Disk

      public Disk(String filename) throws IOException
      Construct a Disk and load the specified file. Read in the entire contents of the file.
      Throws:
      IOException
    • Disk

      public Disk(String filename, boolean knownProDOSOrder) throws IOException
      Construct a Disk and load the specified file. Read in the entire contents of the file.
      Throws:
      IOException
    • Disk

      public Disk(String filename, int startBlocks) throws IOException
      Construct a Disk and load the specified file. Read in the entire contents of the file.
      Throws:
      IOException
    • Disk

      public Disk(String filename, int startBlocks, boolean knownProDOSOrder) throws IOException
      Construct a Disk and load the specified file. Read in the entire contents of the file.
      Throws:
      IOException
  • Method Details

    • getFilenameFilters

      public static Disk.FilenameFilter[] getFilenameFilters()
      Get the supported file filters supported by the Disk interface. This is due to the fact that FilenameFilter is an inner class of Disk - without an instance of the class, the filters cannot be created.
    • getAllExtensions

      public static String[] getAllExtensions()
      Get the supported file extensions supported by the Disk interface. This is used by the Swing UI to populate the open file dialog box.
    • testImageOrder

      public int testImageOrder()
      Test the image order to see if we can recognize a file system. Returns: 0 on recognition; -1 on failure.
    • save

      public void save() throws IOException
      Save a Disk image to its file.
      Throws:
      IOException
    • saveAs

      public void saveAs(String filename) throws IOException
      Save a Disk image as a new/different file.
      Throws:
      IOException
    • getFormattedDisks

      public FormattedDisk[] getFormattedDisks() throws DiskUnrecognizedException
      Determine type of disk, and return the appropriate FormattedDisk object. Throws an Exception if none is recognized.
      Throws:
      DiskUnrecognizedException
    • getDiskImageManager

      public ByteArrayImageLayout getDiskImageManager()
      Returns the diskImageManager.
      Returns:
      ByteArrayImageLayout diskImageManager The disk Image Manager of this disk
    • getFilename

      public String getFilename()
      Returns the filename.
      Returns:
      String
    • setFilename

      public void setFilename(String filename)
      Sets the filename.
    • getOrderName

      public String getOrderName()
      Returns the name of the underlying image order.
      Returns:
      String
    • isCompressed

      public boolean isCompressed()
      Indicate if this disk is GZIP compressed.
    • isSDK

      public boolean isSDK()
      Indicate if this disk is a ShrinkIt-compressed disk image.
    • isSHK

      public boolean isSHK()
      Indicate if this disk is a ShrinkIt-compressed package.
    • isBXY

      public boolean isBXY()
      Indicate if this disk is a ShrinkIt-compressed binary II archive.
    • isProdosOrder

      public boolean isProdosOrder()
      Indicate if this disk is ProDOS ordered (beginning with block 0).
    • isDosOrder

      public boolean isDosOrder()
      Indicate if this disk is DOS ordered (T0,S0 - T35,S15).
    • is2ImgOrder

      public boolean is2ImgOrder()
      Indicate if this disk is a 2IMG disk. This is ProDOS ordered, but with a header on the disk.
    • isNibbleOrder

      public boolean isNibbleOrder()
      Indicate if this disk is a nibbilized disk..
    • getPhysicalSize

      public int getPhysicalSize()
      Identify the size of this disk.
    • resizeDiskImage

      protected void resizeDiskImage(int newSize)
      Resize a disk image up to a larger size. The primary intention is to "fix" disk images that have been created too small. The primary culprit is ApplePC HDV images which dynamically grow. Since AppleCommander works with a byte array, the image must grow to its full size.
      Parameters:
      newSize -
    • readBlock

      public byte[] readBlock(int block)
      Read the block from the disk image.
    • writeBlock

      public void writeBlock(int block, byte[] data)
      Write the block to the disk image.
    • readSector

      public byte[] readSector(int track, int sector) throws IllegalArgumentException
      Retrieve the specified sector.
      Throws:
      IllegalArgumentException
    • writeSector

      public void writeSector(int track, int sector, byte[] bytes) throws IllegalArgumentException
      Write the specified sector.
      Throws:
      IllegalArgumentException
    • isProdosFormat

      public boolean isProdosFormat()
      Test the disk format to see if this is a ProDOS formatted disk.
    • isDosFormat

      public boolean isDosFormat()
      Test the disk format to see if this is a DOS 3.3 formatted disk. This is a little nasty - since 800KB and 140KB images have different characteristics. This just tests 140KB images.
    • isUniDosFormat

      public boolean isUniDosFormat()
      Test the disk format to see if this is a UniDOS formatted disk. UniDOS creates two logical disks on an 800KB physical disk. The first logical disk takes up the first 400KB and the second logical disk takes up the second 400KB.
    • isOzDosFormat

      public boolean isOzDosFormat()
      Test the disk format to see if this is a OzDOS formatted disk. OzDOS creates two logical disks on an 800KB physical disk. The first logical disk takes the first half of each block and the second logical disk takes the second half of each block.
    • isNakedosFormat

      public boolean isNakedosFormat()
      Test the disk format to see if this is a NakedOS formatted disk.
    • isPascalFormat

      public boolean isPascalFormat()
      Test the disk format to see if this is a Pascal formatted disk. Pascal disks may be either 140K or 800K.
    • isCpmFormat

      public boolean isCpmFormat()
      Test the disk format to see if this is a CP/M formatted disk. Check the first 256 bytes of the CP/M directory for validity.
    • is140KbDisk

      protected boolean is140KbDisk()
      Answers true if this disk image is within the expected 140K disk size. Can vary if a header has been applied or if this is a nibblized disk image.
    • is800KbDisk

      protected boolean is800KbDisk()
      Answers true if this disk image is within the expected 800K disk size. Can vary if a 2IMG header has been applied.
    • isRdosFormat

      public boolean isRdosFormat()
      Test the disk format to see if this is a RDOS formatted disk.
    • isRdos33Format

      public boolean isRdos33Format()
      Test the disk format to see if this is a RDOS 33 formatted disk.
    • isWPFormat

      public boolean isWPFormat()
      Test the disk format to see if this is a WP formatted disk.
    • isDC42

      public boolean isDC42()
    • hasChanged

      public boolean hasChanged()
      Indicates if the disk has changed. Triggered when data is written and cleared when data is saved.
    • isNewImage

      public boolean isNewImage()
      Indicates if the disk image is new. This can be used for Save As processing.
    • getImageOrder

      public ImageOrder getImageOrder()
      Answer with the physical ordering of the disk.
    • setImageOrder

      protected void setImageOrder(ImageOrder imageOrder)
      Set the physical ordering of the disk.
    • makeDosOrder

      public void makeDosOrder()
      Change underlying image order to DOS ImageOrder. Assumes this is a 140k disk image.
      See Also:
    • makeProdosOrder

      public void makeProdosOrder()
      Change to a different ImageOrder. Remains in ProDOS format but the underlying order can change.
      See Also:
    • sizeToFit

      public static int sizeToFit(long bytes)
      Find the standard sized disk that will fit the requested number of bytes.
      Returns:
      int size of the disk if it will satisfy the request, -1 otherwise