Class FormattedDisk
java.lang.Object
com.webcodepro.applecommander.storage.FormattedDisk
- All Implemented Interfaces:
DirectoryEntry
- Direct Known Subclasses:
CpmFormatDisk
,DosFormatDisk
,GutenbergFormatDisk
,NakedosFormatDisk
,PascalFormatDisk
,ProdosFormatDisk
,RdosFormatDisk
Abstract representation of a formatted Apple2 disk (floppy, 800k, hard disk).
Date created: Oct 5, 2002 3:51:44 PM
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Use this inner class for label/value mappings in the disk info page.static interface
Use this inner interface for managing the disk usage data.static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
This inner class represents the column header information used in the directory display. -
Constructor Summary
ConstructorsConstructorDescriptionFormattedDisk
(String filename, ImageOrder imageOrder) Constructor for FormattedDisk. -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Indicates if this disk image can delete a file.abstract boolean
Identify if this disk format is capable of having directories.abstract boolean
Indicates if this disk image can read data from a file.abstract boolean
Indicates if this disk image can write data to a file.abstract void
changeImageOrder
(ImageOrder imageOrder) Change the physical ordering of the disk.abstract void
format()
Format the disk.abstract int[]
Get suggested dimensions for display of bitmap.abstract String[]
Get the labels to use in the bitmap.abstract int
Get the length of the bitmap.Return a name for this directory.abstract DiskGeometry
Gives an indication on how this disk's geometry should be handled.Get disk information.abstract String
Return the name of the disk.abstract FormattedDisk.DiskUsage
Get the disk usage iterator.Locate a specific file by filename.protected FileEntry
Recursive routine to locate a specific file by filename.getFileColumnHeaders
(int displayMode) Get the standard file column header information.abstract byte[]
getFileData
(FileEntry fileEntry) Get the data associated with the specified FileEntry.Returns the filename.abstract String[]
Returns a list of possible file types.abstract String
Identify the operating system format of this disk.Get the FormattedDisk associated with this DirectoryEntry.abstract int
Return the amount of free space in bytes.Answer with the physical ordering of the disk.abstract int
Returns the logical disk number.Returns the name of the underlying image order.int
Identify the size of this disk.Returns the source.abstract String
getSuggestedFilename
(String filename) Returns a valid filename for the given filename.abstract String
getSuggestedFiletype
(String filename) Returns a valid filetype for the given filename.abstract int
Return the amount of used space in bytes.boolean
Indicates if the disk has changed.boolean
Indicates if the disk image is new.abstract boolean
needsAddress
(String filetype) Indicates if this filetype requires an address component.byte[]
readBlock
(int block) Read the block from the disk image.byte[]
readSector
(int track, int sector) Retrieve the specified sector.void
Resize the disk image to be its full size.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
setDiskName
(String volumeName) Set the name of the disk to volumeName.abstract void
setFileData
(FileEntry fileEntry, byte[] fileData) Writes the raw bytes into the file.void
setFilename
(String filename) Sets the filename.protected void
setImageOrder
(ImageOrder imageOrder) Set the physical ordering of the disk.abstract boolean
Indicates if this disk format supports "deleted" files.boolean
Indicates if this FormattedDisk supports a disk map.abstract String
toNativeFiletype
(String prodosFiletype) Provides conversation from a given ProDOS file type since as it is common across many archiving tools.abstract String
toProdosFiletype
(String nativeFiletype) Provides conversation to a given ProDOS file type since as it is common across many archiving tools.void
writeBlock
(int block, byte[] data) Write the block to the disk image.protected void
Write the AppleCommander boot code to track 0 sector 0 of the disk.void
writeSector
(int track, int sector, byte[] bytes) Write the specified sector.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.webcodepro.applecommander.storage.DirectoryEntry
canCreateDirectories, canCreateFile, createDirectory, createFile, getFiles
-
Field Details
-
FILE_DISPLAY_STANDARD
public static final int FILE_DISPLAY_STANDARDThis 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:
-
FILE_DISPLAY_NATIVE
public static final int FILE_DISPLAY_NATIVE- See Also:
-
FILE_DISPLAY_DETAIL
public static final int FILE_DISPLAY_DETAIL- See Also:
-
-
Constructor Details
-
FormattedDisk
Constructor for FormattedDisk.
-
-
Method Details
-
getDiskName
Return the name of the disk. Not the physical file name, but "DISK VOLUME #xxx" (DOS 3.3) or "/MY.DISK" (ProDOS). -
getDirname
Return a name for this directory.- Specified by:
getDirname
in interfaceDirectoryEntry
-
setDiskName
Set the name of the disk to volumeName. -
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. -
getDiskUsage
Get the disk usage iterator. -
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
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
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
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:
-
getFile
Locate a specific file by filename. Returns a null if specific filename is not located.- Throws:
DiskException
-
getFile
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
Returns a valid filename for the given filename. This does not necessarily guarantee a unique filename - just validity of the filename. -
getSuggestedFiletype
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
Returns a list of possible file types. Since the filetype is specific to each operating system, a simple String is used. -
needsAddress
Indicates if this filetype requires an address component. -
getFormattedDisk
Get the FormattedDisk associated with this DirectoryEntry. This is useful to interfaces that need to retrieve the associated disk.- Specified by:
getFormattedDisk
in interfaceDirectoryEntry
-
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. -
save
Save a Disk image to its file.- Throws:
IOException
-
saveAs
Save a Disk image as a new/different file.- Throws:
IOException
-
getSource
Returns the source. -
getFilename
Returns the filename.- Returns:
- String
-
setFilename
Sets the filename. -
getOrderName
Returns the name of the underlying image order.- Returns:
- String
-
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
-
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. -
changeImageOrder
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
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
Gives an indication on how this disk's geometry should be handled. -
toNativeFiletype
Provides conversation from a given ProDOS file type since as it is common across many archiving tools. This should also allow "native" filetypes to just pass-through. (For example, a "B" in a DOS disk should just return a "B" while a "BAS" would be transformed to a "B" filetype.) -
toProdosFiletype
Provides conversation to a given ProDOS file type since as it is common across many archiving tools.
-