Class Disk
- java.lang.Object
-
- com.webcodepro.applecommander.storage.Disk
-
- Direct Known Subclasses:
FormattedDisk
public class Disk extends java.lang.ObjectAbstract representation of an Apple2 disk (floppy, 800k, hard disk).Date created: Oct 3, 2002 10:59:47 PM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDisk.FilenameFilterSpecifies a filter to be used in determining filetypes which are supported.
-
Field Summary
Fields Modifier and Type Field Description static intAPPLE_10MB_HARDDISKstatic intAPPLE_140KB_DISKstatic intAPPLE_140KB_NIBBLE_DISKstatic intAPPLE_20MB_HARDDISKstatic intAPPLE_32MB_HARDDISKstatic intAPPLE_5MB_HARDDISKstatic intAPPLE_800KB_2IMG_DISKstatic intAPPLE_800KB_DISKstatic intBLOCK_SIZEstatic intDOS33_SECTORS_ON_140KB_DISKstatic intPRODOS_BLOCKS_ON_140KB_DISKstatic intSECTOR_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description Disk(java.lang.String filename)Construct a Disk and load the specified file.Disk(java.lang.String filename, boolean knownProDOSOrder)Construct a Disk and load the specified file.Disk(java.lang.String filename, int startBlocks)Construct a Disk and load the specified file.Disk(java.lang.String filename, int startBlocks, boolean knownProDOSOrder)Construct a Disk and load the specified file.protectedDisk(java.lang.String filename, ImageOrder imageOrder)Construct a Disk with the given byte array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String[]getAllExtensions()Get the supported file extensions supported by the Disk interface.ByteArrayImageLayoutgetDiskImageManager()Returns the diskImageManager.java.lang.StringgetFilename()Returns the filename.static Disk.FilenameFilter[]getFilenameFilters()Get the supported file filters supported by the Disk interface.FormattedDisk[]getFormattedDisks()Determine type of disk, and return the appropriate FormattedDisk object.ImageOrdergetImageOrder()Answer with the physical ordering of the disk.java.lang.StringgetOrderName()Returns the name of the underlying image order.intgetPhysicalSize()Identify the size of this disk.booleanhasChanged()Indicates if the disk has changed.protected booleanis140KbDisk()Answers true if this disk image is within the expected 140K disk size.booleanis2ImgOrder()Indicate if this disk is a 2IMG disk.protected booleanis800KbDisk()Answers true if this disk image is within the expected 800K disk size.booleanisBXY()Indicate if this disk is a ShrinkIt-compressed binary II archive.booleanisCompressed()Indicate if this disk is GZIP compressed.booleanisCpmFormat()Test the disk format to see if this is a CP/M formatted disk.booleanisDC42()booleanisDosFormat()Test the disk format to see if this is a DOS 3.3 formatted disk.booleanisDosOrder()Indicate if this disk is DOS ordered (T0,S0 - T35,S15).booleanisNakedosFormat()Test the disk format to see if this is a NakedOS formatted disk.booleanisNewImage()Indicates if the disk image is new.booleanisNibbleOrder()Indicate if this disk is a nibbilized disk..booleanisOzDosFormat()Test the disk format to see if this is a OzDOS formatted disk.booleanisPascalFormat()Test the disk format to see if this is a Pascal formatted disk.booleanisProdosFormat()Test the disk format to see if this is a ProDOS formatted disk.booleanisProdosOrder()Indicate if this disk is ProDOS ordered (beginning with block 0).booleanisRdosFormat()Test the disk format to see if this is a RDOS formatted disk.booleanisSDK()Indicate if this disk is a ShrinkIt-compressed disk image.booleanisSHK()Indicate if this disk is a ShrinkIt-compressed package.booleanisUniDosFormat()Test the disk format to see if this is a UniDOS formatted disk.booleanisWPFormat()Test the disk format to see if this is a WP formatted disk.voidmakeDosOrder()Change underlying image order to DOS ImageOrder.voidmakeProdosOrder()Change to a different ImageOrder.byte[]readBlock(int block)Read the block from the disk image.byte[]readSector(int track, int sector)Retrieve the specified sector.protected voidresizeDiskImage(int newSize)Resize a disk image up to a larger size.voidsave()Save a Disk image to its file.voidsaveAs(java.lang.String filename)Save a Disk image as a new/different file.voidsetFilename(java.lang.String filename)Sets the filename.protected voidsetImageOrder(ImageOrder imageOrder)Set the physical ordering of the disk.static intsizeToFit(long bytes)Find the standard sized disk that will fit the requested number of bytes.inttestImageOrder()Test the image order to see if we can recognize a file system.voidwriteBlock(int block, byte[] data)Write the block to the disk image.voidwriteSector(int track, int sector, byte[] bytes)Write the specified sector.
-
-
-
Field Detail
-
BLOCK_SIZE
public static final int BLOCK_SIZE
- See Also:
- Constant Field Values
-
SECTOR_SIZE
public static final int SECTOR_SIZE
- See Also:
- Constant Field Values
-
PRODOS_BLOCKS_ON_140KB_DISK
public static final int PRODOS_BLOCKS_ON_140KB_DISK
- See Also:
- Constant Field Values
-
DOS33_SECTORS_ON_140KB_DISK
public static final int DOS33_SECTORS_ON_140KB_DISK
- See Also:
- Constant Field Values
-
APPLE_140KB_DISK
public static final int APPLE_140KB_DISK
- See Also:
- Constant Field Values
-
APPLE_140KB_NIBBLE_DISK
public static final int APPLE_140KB_NIBBLE_DISK
- See Also:
- Constant Field Values
-
APPLE_800KB_DISK
public static final int APPLE_800KB_DISK
- See Also:
- Constant Field Values
-
APPLE_800KB_2IMG_DISK
public static final int APPLE_800KB_2IMG_DISK
- See Also:
- Constant Field Values
-
APPLE_5MB_HARDDISK
public static final int APPLE_5MB_HARDDISK
- See Also:
- Constant Field Values
-
APPLE_10MB_HARDDISK
public static final int APPLE_10MB_HARDDISK
- See Also:
- Constant Field Values
-
APPLE_20MB_HARDDISK
public static final int APPLE_20MB_HARDDISK
- See Also:
- Constant Field Values
-
APPLE_32MB_HARDDISK
public static final int APPLE_32MB_HARDDISK
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Disk
protected Disk(java.lang.String filename, ImageOrder imageOrder)Construct a Disk with the given byte array.
-
Disk
public Disk(java.lang.String filename) throws java.io.IOExceptionConstruct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
java.io.IOException
-
Disk
public Disk(java.lang.String filename, boolean knownProDOSOrder) throws java.io.IOExceptionConstruct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
java.io.IOException
-
Disk
public Disk(java.lang.String filename, int startBlocks) throws java.io.IOExceptionConstruct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
java.io.IOException
-
Disk
public Disk(java.lang.String filename, int startBlocks, boolean knownProDOSOrder) throws java.io.IOExceptionConstruct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
java.io.IOException
-
-
Method Detail
-
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 java.lang.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 java.io.IOExceptionSave a Disk image to its file.- Throws:
java.io.IOException
-
saveAs
public void saveAs(java.lang.String filename) throws java.io.IOExceptionSave a Disk image as a new/different file.- Throws:
java.io.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 java.lang.String getFilename()
Returns the filename.- Returns:
- String
-
setFilename
public void setFilename(java.lang.String filename)
Sets the filename.
-
getOrderName
public java.lang.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 java.lang.IllegalArgumentExceptionRetrieve the specified sector.- Throws:
java.lang.IllegalArgumentException
-
writeSector
public void writeSector(int track, int sector, byte[] bytes) throws java.lang.IllegalArgumentExceptionWrite the specified sector.- Throws:
java.lang.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.
-
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:
ImageOrder
-
makeProdosOrder
public void makeProdosOrder()
Change to a different ImageOrder. Remains in ProDOS format but the underlying order can change.- See Also:
ImageOrder
-
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
-
-