Class Disk
java.lang.Object
com.webcodepro.applecommander.storage.Disk
- Direct Known Subclasses:
FormattedDisk
Abstract representation of an Apple2 disk (floppy, 800k, hard disk).
Date created: Oct 3, 2002 10:59:47 PM
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Specifies a filter to be used in determining filetypes which are supported. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionConstruct a Disk and load the specified file.Construct a Disk and load the specified file.Construct a Disk and load the specified file.Construct a Disk and load the specified file.protected
Disk
(String filename, ImageOrder imageOrder) Construct a Disk with the given byte array. -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
Get the supported file extensions supported by the Disk interface.Returns the diskImageManager.Returns the filename.static Disk.FilenameFilter[]
Get the supported file filters supported by the Disk interface.Determine type of disk, and return the appropriate FormattedDisk object.Answer with the physical ordering of the disk.Returns the name of the underlying image order.int
Identify the size of this disk.boolean
Indicates if the disk has changed.protected boolean
Answers true if this disk image is within the expected 140K disk size.boolean
Indicate if this disk is a 2IMG disk.protected boolean
Answers true if this disk image is within the expected 800K disk size.boolean
isBXY()
Indicate if this disk is a ShrinkIt-compressed binary II archive.boolean
Indicate if this disk is GZIP compressed.boolean
Test the disk format to see if this is a CP/M formatted disk.boolean
isDC42()
boolean
Test the disk format to see if this is a DOS 3.3 formatted disk.boolean
Indicate if this disk is DOS ordered (T0,S0 - T35,S15).boolean
Test the disk format to see if this is a NakedOS formatted disk.boolean
Indicates if the disk image is new.boolean
Indicate if this disk is a nibbilized disk..boolean
Test the disk format to see if this is a OzDOS formatted disk.boolean
Test the disk format to see if this is a Pascal formatted disk.boolean
Test the disk format to see if this is a ProDOS formatted disk.boolean
Indicate if this disk is ProDOS ordered (beginning with block 0).boolean
Test the disk format to see if this is a RDOS 33 formatted disk.boolean
Test the disk format to see if this is a RDOS formatted disk.boolean
isSDK()
Indicate if this disk is a ShrinkIt-compressed disk image.boolean
isSHK()
Indicate if this disk is a ShrinkIt-compressed package.boolean
Test the disk format to see if this is a UniDOS formatted disk.boolean
Test the disk format to see if this is a WP formatted disk.void
Change underlying image order to DOS ImageOrder.void
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 void
resizeDiskImage
(int newSize) Resize a disk image up to a larger size.void
save()
Save a Disk image to its file.void
Save a Disk image as a new/different file.void
setFilename
(String filename) Sets the filename.protected void
setImageOrder
(ImageOrder imageOrder) Set the physical ordering of the disk.static int
sizeToFit
(long bytes) Find the standard sized disk that will fit the requested number of bytes.int
Test the image order to see if we can recognize a file system.void
writeBlock
(int block, byte[] data) Write the block to the disk image.void
writeSector
(int track, int sector, byte[] bytes) Write the specified sector.
-
Field Details
-
BLOCK_SIZE
public static final int BLOCK_SIZE- See Also:
-
SECTOR_SIZE
public static final int SECTOR_SIZE- See Also:
-
PRODOS_BLOCKS_ON_140KB_DISK
public static final int PRODOS_BLOCKS_ON_140KB_DISK- See Also:
-
DOS33_SECTORS_ON_140KB_DISK
public static final int DOS33_SECTORS_ON_140KB_DISK- See Also:
-
APPLE_140KB_DISK
public static final int APPLE_140KB_DISK- See Also:
-
APPLE_140KB_NIBBLE_DISK
public static final int APPLE_140KB_NIBBLE_DISK- See Also:
-
APPLE_800KB_DISK
public static final int APPLE_800KB_DISK- See Also:
-
APPLE_800KB_2IMG_DISK
public static final int APPLE_800KB_2IMG_DISK- See Also:
-
APPLE_5MB_HARDDISK
public static final int APPLE_5MB_HARDDISK- See Also:
-
APPLE_10MB_HARDDISK
public static final int APPLE_10MB_HARDDISK- See Also:
-
APPLE_20MB_HARDDISK
public static final int APPLE_20MB_HARDDISK- See Also:
-
APPLE_32MB_HARDDISK
public static final int APPLE_32MB_HARDDISK- See Also:
-
-
Constructor Details
-
Disk
Construct a Disk with the given byte array. -
Disk
Construct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
IOException
-
Disk
Construct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
IOException
-
Disk
Construct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
IOException
-
Disk
Construct a Disk and load the specified file. Read in the entire contents of the file.- Throws:
IOException
-
-
Method Details
-
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
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
Save a Disk image to its file.- Throws:
IOException
-
saveAs
Save a Disk image as a new/different file.- Throws:
IOException
-
getFormattedDisks
Determine type of disk, and return the appropriate FormattedDisk object. Throws an Exception if none is recognized.- Throws:
DiskUnrecognizedException
-
getDiskImageManager
Returns the diskImageManager.- Returns:
- ByteArrayImageLayout diskImageManager The disk Image Manager of this disk
-
getFilename
Returns the filename.- Returns:
- String
-
setFilename
Sets the filename. -
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
Retrieve the specified sector.- Throws:
IllegalArgumentException
-
writeSector
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
Answer with the physical ordering of the disk. -
setImageOrder
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
-