Class CpmFormatDisk
- java.lang.Object
-
- com.webcodepro.applecommander.storage.Disk
-
- com.webcodepro.applecommander.storage.FormattedDisk
-
- com.webcodepro.applecommander.storage.os.cpm.CpmFormatDisk
-
- All Implemented Interfaces:
DirectoryEntry
public class CpmFormatDisk extends FormattedDisk
Manages a disk that is in the Apple CP/M format.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CpmFormatDisk.CpmDiskUsage
Manage CP/M disk usage.-
Nested classes/interfaces inherited from class com.webcodepro.applecommander.storage.FormattedDisk
FormattedDisk.DiskInformation, FormattedDisk.DiskUsage, FormattedDisk.FileColumnHeader
-
Nested classes/interfaces inherited from class com.webcodepro.applecommander.storage.Disk
Disk.FilenameFilter
-
-
Field Summary
Fields Modifier and Type Field Description static int
CPM_BLOCKS_PER_TRACK
The number of CP/M blocks per physical track.static int
CPM_BLOCKSIZE
The size of a CP/M block.static int
CPM_SECTORS_PER_CPM_BLOCK
The number of CP/M sectors per CP/M block.static int
CPM_SECTORSIZE
The size of the CP/M sector.static int
PHYSICAL_BLOCK_TRACK_START
The track number which CP/M block #0 resides at.static int
PHYSICAL_SECTORS_PER_BLOCK
The number of physical sectors per CP/M block.static int[]
sectorSkew
The sector skew of the CP/M disk image.-
Fields inherited from class com.webcodepro.applecommander.storage.FormattedDisk
FILE_DISPLAY_DETAIL, FILE_DISPLAY_NATIVE, FILE_DISPLAY_STANDARD
-
Fields inherited from class com.webcodepro.applecommander.storage.Disk
APPLE_10MB_HARDDISK, APPLE_140KB_DISK, APPLE_140KB_NIBBLE_DISK, APPLE_20MB_HARDDISK, APPLE_32MB_HARDDISK, APPLE_5MB_HARDDISK, APPLE_800KB_2IMG_DISK, APPLE_800KB_DISK, BLOCK_SIZE, DOS33_SECTORS_ON_140KB_DISK, PRODOS_BLOCKS_ON_140KB_DISK, SECTOR_SIZE
-
-
Constructor Summary
Constructors Constructor Description CpmFormatDisk(java.lang.String filename, ImageOrder imageOrder)
Construct a CP/M formatted disk.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canCreateDirectories()
Identify if additional directories can be created.boolean
canCreateFile()
Indicates if this disk image can create a file.boolean
canDeleteFile()
Indicates if this disk image can delete a file.boolean
canHaveDirectories()
Identify if this disk format is capable of having directories.boolean
canReadFileData()
Indicates if this disk image can read data from a file.boolean
canWriteFileData()
Indicates if this disk image can write data to a file.void
changeImageOrder(ImageOrder imageOrder)
Change to a different ImageOrder.protected int
computeSector(int block)
Compute the physical sector number.protected int
computeTrack(int block)
Compute the physical track number.static CpmFormatDisk[]
create(java.lang.String filename, ImageOrder imageOrder)
Create a CpmFormatDisk.DirectoryEntry
createDirectory(java.lang.String name)
Create a new DirectoryEntry.FileEntry
createFile()
Create a new FileEntry.void
format()
Format the disk.java.lang.String
fromProdosFiletype(java.lang.String prodosFiletype)
Provides conversation from a given ProDOS file type since as it is common across many archiving tools.int[]
getBitmapDimensions()
Get suggested dimensions for display of bitmap.java.lang.String[]
getBitmapLabels()
Get the labels to use in the bitmap.int
getBitmapLength()
Get the length of the bitmap.int
getBlocksUsed()
Compute the number of CP/M blocks that are currently used.DiskGeometry
getDiskGeometry()
Gives an indication on how this disk's geometry should be handled.java.lang.String
getDiskName()
There apparently is no corresponding CP/M disk name.FormattedDisk.DiskUsage
getDiskUsage()
Get the disk usage iterator.java.util.List<FormattedDisk.FileColumnHeader>
getFileColumnHeaders(int displayMode)
Get the standard file column header information.byte[]
getFileData(FileEntry fileEntry)
Get the data associated with the specified FileEntry.java.util.List<FileEntry>
getFiles()
Answer with a list of file entries.java.lang.String[]
getFiletypes()
Returns a list of possible file types.java.lang.String
getFormat()
Identify the operating system format of this disk.int
getFreeSpace()
Return the amount of free space in bytes.int
getLogicalDiskNumber()
Returns the logical disk number.java.lang.String
getSuggestedFilename(java.lang.String filename)
Returns a valid filename for the given filename.java.lang.String
getSuggestedFiletype(java.lang.String filetype)
Returns a valid filetype for the given filename.int
getUsedSpace()
Return the amount of used space in bytes.boolean
needsAddress(java.lang.String filetype)
Indicates if this filetype requires an address component.byte[]
readCpmBlock(int block)
Read a CP/M block (1K in size).byte[]
readCpmFileEntries()
void
setFileData(FileEntry fileEntry, byte[] fileData)
Writes the raw bytes into the file.boolean
supportsDeletedFiles()
Indicates if this disk format supports "deleted" files.boolean
supportsDiskMap()
Indicates if this FormattedDisk supports a disk map.java.lang.String
toProdosFiletype(java.lang.String nativeFiletype)
Provides conversation to a given ProDOS file type since as it is common across many archiving tools.void
writeCpmBlock(int block, byte[] data)
Write a CP/M block.void
writeCpmFileEntries(byte[] data)
-
Methods inherited from class com.webcodepro.applecommander.storage.FormattedDisk
getDirname, getDiskInformation, getFile, getFile, getFormattedDisk, resizeDiskImage, setDiskName, writeBootCode
-
Methods inherited from class com.webcodepro.applecommander.storage.Disk
getAllExtensions, getDiskImageManager, getFilename, getFilenameFilters, getFormattedDisks, getImageOrder, getOrderName, getPhysicalSize, hasChanged, is140KbDisk, is2ImgOrder, is800KbDisk, isBXY, isCompressed, isCpmFormat, isDC42, isDosFormat, isDosOrder, isNakedosFormat, isNewImage, isNibbleOrder, isOzDosFormat, isPascalFormat, isProdosFormat, isProdosOrder, isRdos33Format, isRdosFormat, isSDK, isSHK, isUniDosFormat, isWPFormat, makeDosOrder, makeProdosOrder, readBlock, readSector, resizeDiskImage, save, saveAs, setFilename, setImageOrder, sizeToFit, testImageOrder, writeBlock, writeSector
-
-
-
-
Field Detail
-
CPM_SECTORSIZE
public static final int CPM_SECTORSIZE
The size of the CP/M sector. Assumed to be 128.- See Also:
- Constant Field Values
-
CPM_BLOCKSIZE
public static final int CPM_BLOCKSIZE
The size of a CP/M block. Assumed to be 1K.- See Also:
- Constant Field Values
-
CPM_SECTORS_PER_CPM_BLOCK
public static final int CPM_SECTORS_PER_CPM_BLOCK
The number of CP/M sectors per CP/M block.- See Also:
- Constant Field Values
-
CPM_BLOCKS_PER_TRACK
public static final int CPM_BLOCKS_PER_TRACK
The number of CP/M blocks per physical track.- See Also:
- Constant Field Values
-
PHYSICAL_SECTORS_PER_BLOCK
public static final int PHYSICAL_SECTORS_PER_BLOCK
The number of physical sectors per CP/M block.- See Also:
- Constant Field Values
-
PHYSICAL_BLOCK_TRACK_START
public static final int PHYSICAL_BLOCK_TRACK_START
The track number which CP/M block #0 resides at. (The other tracks are boot-related and not available.)- See Also:
- Constant Field Values
-
sectorSkew
public static final int[] sectorSkew
The sector skew of the CP/M disk image.
-
-
Constructor Detail
-
CpmFormatDisk
public CpmFormatDisk(java.lang.String filename, ImageOrder imageOrder)
Construct a CP/M formatted disk.
-
-
Method Detail
-
create
public static CpmFormatDisk[] create(java.lang.String filename, ImageOrder imageOrder)
Create a CpmFormatDisk. All CP/M disk images are expected to be 140K in size.
-
getDiskName
public java.lang.String getDiskName()
There apparently is no corresponding CP/M disk name.- Specified by:
getDiskName
in classFormattedDisk
- See Also:
FormattedDisk.getDiskName()
-
getFormat
public java.lang.String getFormat()
Identify the operating system format of this disk.- Specified by:
getFormat
in classFormattedDisk
- See Also:
FormattedDisk.getFormat()
-
getFreeSpace
public int getFreeSpace()
Return the amount of free space in bytes.- Specified by:
getFreeSpace
in classFormattedDisk
- See Also:
FormattedDisk.getFreeSpace()
-
getUsedSpace
public int getUsedSpace()
Return the amount of used space in bytes.- Specified by:
getUsedSpace
in classFormattedDisk
- See Also:
FormattedDisk.getUsedSpace()
-
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:
getBitmapDimensions
in classFormattedDisk
- See Also:
FormattedDisk.getBitmapDimensions()
-
getBitmapLength
public int getBitmapLength()
Get the length of the bitmap. This is hard-coded to 140.- Specified by:
getBitmapLength
in classFormattedDisk
- See Also:
FormattedDisk.getBitmapLength()
-
getDiskUsage
public FormattedDisk.DiskUsage getDiskUsage()
Get the disk usage iterator.- Specified by:
getDiskUsage
in classFormattedDisk
- See Also:
FormattedDisk.getDiskUsage()
-
getBitmapLabels
public java.lang.String[] getBitmapLabels()
Get the labels to use in the bitmap.- Specified by:
getBitmapLabels
in classFormattedDisk
- See Also:
FormattedDisk.getBitmapLabels()
-
supportsDeletedFiles
public boolean supportsDeletedFiles()
Indicates if this disk format supports "deleted" files.- Specified by:
supportsDeletedFiles
in classFormattedDisk
- See Also:
FormattedDisk.supportsDeletedFiles()
-
canReadFileData
public boolean canReadFileData()
Indicates if this disk image can read data from a file.- Specified by:
canReadFileData
in classFormattedDisk
- See Also:
FormattedDisk.canReadFileData()
-
canWriteFileData
public boolean canWriteFileData()
Indicates if this disk image can write data to a file.- Specified by:
canWriteFileData
in classFormattedDisk
- See Also:
FormattedDisk.canWriteFileData()
-
canHaveDirectories
public boolean canHaveDirectories()
Identify if this disk format is capable of having directories.- Specified by:
canHaveDirectories
in classFormattedDisk
- See Also:
FormattedDisk.canHaveDirectories()
-
canDeleteFile
public boolean canDeleteFile()
Indicates if this disk image can delete a file.- Specified by:
canDeleteFile
in classFormattedDisk
- See Also:
FormattedDisk.canDeleteFile()
-
getFileData
public byte[] getFileData(FileEntry fileEntry)
Get the data associated with the specified FileEntry. This is just the raw data. Use the FileEntry itself to read data appropriately!- Specified by:
getFileData
in classFormattedDisk
- See Also:
FormattedDisk.getFileData(com.webcodepro.applecommander.storage.FileEntry)
-
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:
format
in classFormattedDisk
- See Also:
FormattedDisk.format()
-
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:
getLogicalDiskNumber
in classFormattedDisk
- See Also:
FormattedDisk.getLogicalDiskNumber()
-
getSuggestedFilename
public java.lang.String getSuggestedFilename(java.lang.String filename)
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:
getSuggestedFilename
in classFormattedDisk
- See Also:
FormattedDisk.getSuggestedFilename(java.lang.String)
-
getSuggestedFiletype
public java.lang.String getSuggestedFiletype(java.lang.String filetype)
Returns a valid filetype for the given filename. Rules are very similar to the filename, but trim to 3 characters.- Specified by:
getSuggestedFiletype
in classFormattedDisk
- See Also:
FormattedDisk.getSuggestedFiletype(java.lang.String)
-
getFiletypes
public java.lang.String[] getFiletypes()
Returns a list of possible file types. Since the filetype is specific to each operating system, a simple String is used.- Specified by:
getFiletypes
in classFormattedDisk
- See Also:
FormattedDisk.getFiletypes()
-
needsAddress
public boolean needsAddress(java.lang.String filetype)
Indicates if this filetype requires an address component.- Specified by:
needsAddress
in classFormattedDisk
- See Also:
FormattedDisk.needsAddress(java.lang.String)
-
getFiles
public java.util.List<FileEntry> getFiles()
Answer with a list of file entries.- See Also:
DirectoryEntry.getFiles()
-
createFile
public FileEntry createFile() throws DiskFullException
Create a new FileEntry.- Throws:
DiskFullException
- See Also:
DirectoryEntry.createFile()
-
canCreateDirectories
public boolean canCreateDirectories()
Identify if additional directories can be created. CP/M doesn't support directories.- See Also:
DirectoryEntry.canCreateDirectories()
-
canCreateFile
public boolean canCreateFile()
Indicates if this disk image can create a file.- See Also:
DirectoryEntry.canCreateFile()
-
readCpmBlock
public byte[] readCpmBlock(int block)
Read a CP/M block (1K in size).
-
readCpmFileEntries
public byte[] readCpmFileEntries()
-
writeCpmFileEntries
public void writeCpmFileEntries(byte[] data)
-
computeTrack
protected int computeTrack(int block)
Compute the physical track number.
-
computeSector
protected int computeSector(int block)
Compute the physical sector number. The rest of the block follows in sequential order.
-
writeCpmBlock
public void writeCpmBlock(int block, byte[] data)
Write a CP/M block.
-
getFileColumnHeaders
public java.util.List<FormattedDisk.FileColumnHeader> getFileColumnHeaders(int displayMode)
Get the standard file column header information. This default implementation is intended only for standard mode.- Overrides:
getFileColumnHeaders
in classFormattedDisk
-
supportsDiskMap
public boolean supportsDiskMap()
Indicates if this FormattedDisk supports a disk map.- Overrides:
supportsDiskMap
in classFormattedDisk
-
changeImageOrder
public void changeImageOrder(ImageOrder imageOrder)
Change to a different ImageOrder. Remains in CP/M format but the underlying order can change.- Specified by:
changeImageOrder
in classFormattedDisk
- See Also:
ImageOrder
-
setFileData
public void setFileData(FileEntry fileEntry, byte[] fileData) throws DiskFullException
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:
setFileData
in classFormattedDisk
- Throws:
DiskFullException
-
createDirectory
public DirectoryEntry createDirectory(java.lang.String name) throws DiskFullException
Create a new DirectoryEntry.- Throws:
DiskFullException
- See Also:
DirectoryEntry.createDirectory(String)
-
getDiskGeometry
public DiskGeometry getDiskGeometry()
Gives an indication on how this disk's geometry should be handled.- Specified by:
getDiskGeometry
in classFormattedDisk
-
fromProdosFiletype
public java.lang.String fromProdosFiletype(java.lang.String prodosFiletype)
Provides conversation from a given ProDOS file type since as it is common across many archiving tools.- Specified by:
fromProdosFiletype
in classFormattedDisk
-
toProdosFiletype
public java.lang.String toProdosFiletype(java.lang.String nativeFiletype)
Provides conversation to a given ProDOS file type since as it is common across many archiving tools.- Specified by:
toProdosFiletype
in classFormattedDisk
-
-