Class CpmFormatDisk
java.lang.Object
com.webcodepro.applecommander.storage.FormattedDisk
com.webcodepro.applecommander.storage.os.cpm.CpmFormatDisk
- All Implemented Interfaces:
DirectoryEntry,Container
Manages a disk that is in the Apple CP/M format.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.webcodepro.applecommander.storage.FormattedDisk
FormattedDisk.DiskInformation, FormattedDisk.DiskUsage, FormattedDisk.FileColumnHeader -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe number of CP/M blocks per physical track.static final intThe size of a CP/M block.static final intThe number of CP/M sectors per CP/M block.static final intThe size of the CP/M sector.static final intThe underlying block number which CP/M data block #0 resides.static final intThe track number which CP/M block #0 resides at.static final intThe number of physical sectors per CP/M block.Fields inherited from class com.webcodepro.applecommander.storage.FormattedDisk
FILE_DISPLAY_DETAIL, FILE_DISPLAY_NATIVE, FILE_DISPLAY_STANDARD -
Constructor Summary
ConstructorsConstructorDescriptionCpmFormatDisk(String filename, BlockDevice device) Construct a CP/M formatted disk. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIdentify if additional directories can be created.booleanIndicates if this disk image can create a file.booleanIndicates if this disk image can delete a file.booleanIdentify if this disk format is capable of having directories.booleanIndicates if this disk image can read data from a file.booleanIndicates if this disk image can write data to a file.static CpmFormatDisk[]create(String filename, BlockDevice device) Create a CpmFormatDisk.createDirectory(String name) Create a new DirectoryEntry.Create a new FileEntry.voidformat()Format the disk.<T> Optional<T> int[]Get suggested dimensions for display of bitmap.String[]Get the labels to use in the bitmap.intGet the length of the bitmap.intCompute the number of CP/M blocks that are currently used.Gives an indication on how this disk's geometry should be handled.There apparently is no corresponding CP/M disk name.Get the disk usage iterator.getFileColumnHeaders(int displayMode) Get the standard file column header information.byte[]getFileData(FileEntry fileEntry) Get the data associated with the specified FileEntry.getFiles()Answer with a list of file entries.String[]Returns a list of possible file types.Identify the operating system format of this disk.intReturn the amount of free space in bytes.intReturns the logical disk number.getSuggestedFilename(String filename) Returns a valid filename for the given filename.getSuggestedFiletype(String filetype) Returns a valid filetype for the given filename.intReturn the amount of used space in bytes.booleanneedsAddress(String filetype) Indicates if this filetype requires an address component.byte[]voidsetFileData(FileEntry fileEntry, byte[] fileData) Writes the raw bytes into the file.booleanIndicates if this disk format supports "deleted" files.booleanIndicates if this FormattedDisk supports a disk map.toNativeFiletype(String prodosFiletype) Provides conversation from a given ProDOS file type since as it is common across many archiving tools.toProdosFiletype(String nativeFiletype) Provides conversation to a given ProDOS file type since as it is common across many archiving tools.voidwriteCpmFileEntries(byte[] data) Methods inherited from class com.webcodepro.applecommander.storage.FormattedDisk
getBootCode, getDirname, getDiskInformation, getFile, getFile, getFilename, getFormattedDisk, getSource, hasChanged, isNewImage, resizeDiskImage, resizeDiskImage, save, saveAs, setDiskName, setFilename
-
Field Details
-
CPM_SECTORSIZE
public static final int CPM_SECTORSIZEThe size of the CP/M sector. Assumed to be 128.- See Also:
-
CPM_BLOCKSIZE
public static final int CPM_BLOCKSIZEThe size of a CP/M block. Assumed to be 1K.- See Also:
-
CPM_SECTORS_PER_CPM_BLOCK
public static final int CPM_SECTORS_PER_CPM_BLOCKThe number of CP/M sectors per CP/M block.- See Also:
-
CPM_BLOCKS_PER_TRACK
public static final int CPM_BLOCKS_PER_TRACKThe number of CP/M blocks per physical track.- See Also:
-
PHYSICAL_SECTORS_PER_BLOCK
public static final int PHYSICAL_SECTORS_PER_BLOCKThe number of physical sectors per CP/M block.- See Also:
-
PHYSICAL_BLOCK_TRACK_START
public static final int PHYSICAL_BLOCK_TRACK_STARTThe track number which CP/M block #0 resides at. (The other tracks are boot-related and not available.)- See Also:
-
FIRST_DATA_BLOCK
public static final int FIRST_DATA_BLOCKThe underlying block number which CP/M data block #0 resides.- See Also:
-
-
Constructor Details
-
CpmFormatDisk
Construct a CP/M formatted disk.
-
-
Method Details
-
create
Create a CpmFormatDisk. All CP/M disk images are expected to be 140K in size. -
get
-
getDiskName
There apparently is no corresponding CP/M disk name.- Specified by:
getDiskNamein classFormattedDisk- See Also:
-
getFormat
Identify the operating system format of this disk.- Specified by:
getFormatin classFormattedDisk- See Also:
-
getFreeSpace
public int getFreeSpace()Return the amount of free space in bytes.- Specified by:
getFreeSpacein classFormattedDisk- See Also:
-
getUsedSpace
public int getUsedSpace()Return the amount of used space in bytes.- Specified by:
getUsedSpacein classFormattedDisk- See Also:
-
getBlocksUsed
public int getBlocksUsed()Compute the number of CP/M blocks that are currently used. -
getBitmapDimensions
public 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.- Specified by:
getBitmapDimensionsin classFormattedDisk- See Also:
-
getBitmapLength
public int getBitmapLength()Get the length of the bitmap. This is hard-coded to 140.- Specified by:
getBitmapLengthin classFormattedDisk- See Also:
-
getDiskUsage
Get the disk usage iterator.- Specified by:
getDiskUsagein classFormattedDisk- See Also:
-
getBitmapLabels
Get the labels to use in the bitmap.- Specified by:
getBitmapLabelsin classFormattedDisk- See Also:
-
supportsDeletedFiles
public boolean supportsDeletedFiles()Indicates if this disk format supports "deleted" files.- Specified by:
supportsDeletedFilesin classFormattedDisk- See Also:
-
canReadFileData
public boolean canReadFileData()Indicates if this disk image can read data from a file.- Specified by:
canReadFileDatain classFormattedDisk- See Also:
-
canWriteFileData
public boolean canWriteFileData()Indicates if this disk image can write data to a file.- Specified by:
canWriteFileDatain classFormattedDisk- See Also:
-
canHaveDirectories
public boolean canHaveDirectories()Identify if this disk format is capable of having directories.- Specified by:
canHaveDirectoriesin classFormattedDisk- See Also:
-
canDeleteFile
public boolean canDeleteFile()Indicates if this disk image can delete a file.- Specified by:
canDeleteFilein classFormattedDisk- See Also:
-
getFileData
Get the data associated with the specified FileEntry. This is just the raw data. Use the FileEntry itself to read data appropriately!- Specified by:
getFileDatain classFormattedDisk- See Also:
-
format
public void format()Format the disk. Simply wipes the disk to all 0xE5 - this seems to be the standard (or a requirement).Note: Assumes that this is a 140K CP/M disk of 35 tracks and 16 physical sectors.
- Specified by:
formatin classFormattedDisk- See Also:
-
getLogicalDiskNumber
public 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.- Specified by:
getLogicalDiskNumberin classFormattedDisk- See Also:
-
getSuggestedFilename
Returns a valid filename for the given filename. The assumed rules are that the name must be 8 characters long (padded on the end with spaces) and alphanumeric, starting with a character.- Specified by:
getSuggestedFilenamein classFormattedDisk- See Also:
-
getSuggestedFiletype
Returns a valid filetype for the given filename. Rules are very similar to the filename, but trim to 3 characters.- Specified by:
getSuggestedFiletypein classFormattedDisk- See Also:
-
getFiletypes
Returns a list of possible file types. Since the filetype is specific to each operating system, a simple String is used.- Specified by:
getFiletypesin classFormattedDisk- See Also:
-
needsAddress
Indicates if this filetype requires an address component.- Specified by:
needsAddressin classFormattedDisk- See Also:
-
getFiles
Answer with a list of file entries.- See Also:
-
createFile
Create a new FileEntry.- Throws:
DiskFullException- See Also:
-
canCreateDirectories
public boolean canCreateDirectories()Identify if additional directories can be created. CP/M doesn't support directories.- See Also:
-
canCreateFile
public boolean canCreateFile()Indicates if this disk image can create a file.- See Also:
-
readCpmFileEntries
public byte[] readCpmFileEntries() -
writeCpmFileEntries
public void writeCpmFileEntries(byte[] data) -
getFileColumnHeaders
Get the standard file column header information. This default implementation is intended only for standard mode.- Overrides:
getFileColumnHeadersin classFormattedDisk
-
supportsDiskMap
public boolean supportsDiskMap()Indicates if this FormattedDisk supports a disk map.- Overrides:
supportsDiskMapin classFormattedDisk
-
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.- Specified by:
setFileDatain classFormattedDisk
-
createDirectory
Create a new DirectoryEntry.- See Also:
-
getDiskGeometry
Gives an indication on how this disk's geometry should be handled.- Specified by:
getDiskGeometryin classFormattedDisk
-
toNativeFiletype
Provides conversation from a given ProDOS file type since as it is common across many archiving tools.- Specified by:
toNativeFiletypein classFormattedDisk
-
toProdosFiletype
Provides conversation to a given ProDOS file type since as it is common across many archiving tools.- Specified by:
toProdosFiletypein classFormattedDisk
-