Class ProdosFormatDisk
java.lang.Object
com.webcodepro.applecommander.storage.FormattedDisk
com.webcodepro.applecommander.storage.os.prodos.ProdosFormatDisk
- All Implemented Interfaces:
DirectoryEntry,Container
Manages a disk that is in the ProDOS format.
Date created: Oct 3, 2002 11:45:25 PM
-
Nested Class Summary
Nested classes/interfaces inherited from class com.webcodepro.applecommander.storage.FormattedDisk
FormattedDisk.DiskInformation, FormattedDisk.DiskUsage, FormattedDisk.FileColumnHeader -
Field Summary
Fields inherited from class com.webcodepro.applecommander.storage.FormattedDisk
FILE_DISPLAY_DETAIL, FILE_DISPLAY_NATIVE, FILE_DISPLAY_STANDARD -
Constructor Summary
ConstructorsConstructorDescriptionProdosFormatDisk(String filename, BlockDevice device) Constructor for ProdosFormatDisk. -
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 ProdosFormatDisk[]create(String filename, String diskName, BlockDevice device) Create a ProdosFormatDisk.createDirectory(ProdosCommonDirectoryHeader directory, String name) Create a new DirectoryEntry.createDirectory(String name) Create a new DirectoryEntry.Create a FileEntry in the Volume Directory.createFile(ProdosCommonDirectoryHeader directory) Create a FileEntry in the given directory.static booleanfileTypeNeedsAddress(String filetype) Utility method to indicate if this file type needs an address.protected intfindFreeBlock(byte[] volumeBitmap) Locate a free block in the Volume Bitmap.voidformat()Format the ProDOS volume.protected voidfreeBlocks(ProdosFileEntry prodosFileEntry) Free blocks used by a ProdosFileEntry.<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.Gives an indication on how this disk's geometry should be handled.Get Pascal-specific disk information.Return the name of the disk.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()Retrieve a list of files.getFiles(int blockNumber) Build a list of files, starting in the given block number.static StringgetFiletype(int filetype) Return the filetype of this file.bytegetFiletype(String filetype) Get the numerical filetype.String[]Returns a list of possible file types.Identify the operating system format of this disk.intReturn the number of free blocks on the disk.intReturn the amount of free space in bytes.protected intgetIndexBlockData(byte[] fileData, byte[] indexBlock, int offset) Read file data from the given index block.intReturns the logical disk number.getSuggestedFilename(String filename) Returns a valid filename for the given filename.getSuggestedFiletype(String filename) Returns a valid filetype for the given filename.intReturn the number of used blocks on the disk.intReturn the amount of used space in bytes.protected ProdosVolumeDirectoryHeaderbooleanisBlockFree(byte[] data, int blockNumber) Determine if the specified block is free.booleanisBlockUsed(byte[] data, int blockNumber) Determine if the specified block is used.booleanneedsAddress(String filetype) Indicates if this filetype requires an address component.protected byte[]readBlock(int block) byte[]Read the Volume Bit Map.voidsetBlockFree(byte[] data, int blockNumber) Set if the specified block is free.voidsetBlockUsed(byte[] data, int blockNumber) Set if the specified block is free.voidsetDiskName(String volumeName) Set the name of the disk (volume name).voidsetFileData(FileEntry fileEntry, byte[] fileData) Writes the raw bytes into the file.protected voidsetFileData(ProdosFileEntry fileEntry, byte[] fileData) Set the data associated with the specified ProdosFileEntry into sectors on the disk.protected voidsetFileData(ProdosFileEntry fileEntry, byte[] dataFork, byte[] resourceFork) Set the data associated with the specified ProdosFileEntry into sectors on the disk.protected voidsetGEOSFileData(ProdosFileEntry fileEntry, byte[] fileData) Set the data associated with the specified ProdosFileEntry into sectors on the disk.protected voidsetGEOSSaplingData(byte[] bitmap, ProdosFileEntry fileEntry, byte[] fileData) Set the GEOS "sapling" file data.protected voidsetGEOSTreeData(byte[] bitmap, ProdosFileEntry fileEntry, byte[] fileData) Set the GEOS "tree" file data.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.protected voidwriteBlock(int block, byte[] data) voidwriteVolumeBitMap(byte[] data) Write the Volume Bit Map.Methods inherited from class com.webcodepro.applecommander.storage.FormattedDisk
getBootCode, getDirname, getFile, getFile, getFilename, getFormattedDisk, getSource, hasChanged, isNewImage, resizeDiskImage, resizeDiskImage, save, saveAs, setFilename
-
Constructor Details
-
ProdosFormatDisk
Constructor for ProdosFormatDisk.
-
-
Method Details
-
create
Create a ProdosFormatDisk. -
get
-
getFormat
Identify the operating system format of this disk.- Specified by:
getFormatin classFormattedDisk- See Also:
-
createFile
Create a FileEntry in the Volume Directory.- Throws:
DiskFullException
-
readBlock
protected byte[] readBlock(int block) -
writeBlock
protected void writeBlock(int block, byte[] data) -
createFile
Create a FileEntry in the given directory.- Throws:
DiskFullException
-
getFiles
Retrieve a list of files.- Throws:
DiskException- See Also:
-
getFiles
Build a list of files, starting in the given block number. This works for the master as well as the subdirectories.- Throws:
DiskException
-
getFreeSpace
public int getFreeSpace()Return the amount of free space in bytes.- Specified by:
getFreeSpacein classFormattedDisk- See Also:
-
getFreeBlocks
public int getFreeBlocks()Return the number of free blocks on the disk. -
getUsedSpace
public int getUsedSpace()Return the amount of used space in bytes.- Specified by:
getUsedSpacein classFormattedDisk- See Also:
-
getUsedBlocks
public int getUsedBlocks()Return the number of used blocks on the disk. -
canCreateDirectories
public boolean canCreateDirectories()Identify if additional directories can be created. This may indicate that directories are not available to this operating system or simply that the disk image is "locked" to writing. -
canCreateFile
public boolean canCreateFile()Indicates if this disk image can create a file. If not, the reason may be as simple as it has not beem implemented to something specific about the disk. -
getDiskName
Return the name of the disk.- Specified by:
getDiskNamein classFormattedDisk- See Also:
-
setDiskName
Set the name of the disk (volume name).- Overrides:
setDiskNamein classFormattedDisk
-
getBitmapDimensions
public int[] getBitmapDimensions()Get suggested dimensions for display of bitmap. There is no suggestion for a ProDOS volume - it is just a series of blocks.- Specified by:
getBitmapDimensionsin classFormattedDisk
-
getBitmapLength
public int getBitmapLength()Get the length of the bitmap.- Specified by:
getBitmapLengthin classFormattedDisk
-
getDiskUsage
Get the disk usage iterator.- Specified by:
getDiskUsagein classFormattedDisk
-
getBitmapLabels
Get the labels to use in the bitmap.- Specified by:
getBitmapLabelsin classFormattedDisk
-
getDiskInformation
Get Pascal-specific disk information.- Overrides:
getDiskInformationin classFormattedDisk
-
getFileColumnHeaders
Get the standard file column header information. This default implementation is intended only for standard mode.- Overrides:
getFileColumnHeadersin classFormattedDisk
-
supportsDeletedFiles
public boolean supportsDeletedFiles()Indicates if this disk format supports "deleted" files.- Specified by:
supportsDeletedFilesin classFormattedDisk
-
canReadFileData
public boolean canReadFileData()Indicates if this disk image can read data from a file.- Specified by:
canReadFileDatain classFormattedDisk
-
canHaveDirectories
public boolean canHaveDirectories()Identify if this disk format is capable of having directories.- Specified by:
canHaveDirectoriesin classFormattedDisk- See Also:
-
canWriteFileData
public boolean canWriteFileData()Indicates if this disk image can write data to a file.- Specified by:
canWriteFileDatain classFormattedDisk
-
canDeleteFile
public boolean canDeleteFile()Indicates if this disk image can delete a file.- Specified by:
canDeleteFilein classFormattedDisk
-
getFileData
Get the data associated with the specified FileEntry. Note that this could return a 16MB file! Sparse files are not treated specially.- Specified by:
getFileDatain classFormattedDisk- See Also:
-
freeBlocks
Free blocks used by a ProdosFileEntry. -
getIndexBlockData
protected int getIndexBlockData(byte[] fileData, byte[] indexBlock, int offset) Read file data from the given index block. Note that block number 0 is an unused block. -
setFileData
Set the data associated with the specified ProdosFileEntry into sectors on the disk. Automatically grows the filesystem structures from seedling to sapling to tree.- Throws:
DiskFullException
-
setFileData
protected void setFileData(ProdosFileEntry fileEntry, byte[] dataFork, byte[] resourceFork) throws DiskFullException Set the data associated with the specified ProdosFileEntry into sectors on the disk. Automatically grows the filesystem structures from seedling to sapling to tree.- Throws:
DiskFullException
-
setGEOSFileData
Set the data associated with the specified ProdosFileEntry into sectors on the disk. Take GEOS file structures into account.- Throws:
DiskFullException
-
setGEOSSaplingData
protected void setGEOSSaplingData(byte[] bitmap, ProdosFileEntry fileEntry, byte[] fileData) throws DiskFullException Set the GEOS "sapling" file data.- Throws:
DiskFullException
-
setGEOSTreeData
protected void setGEOSTreeData(byte[] bitmap, ProdosFileEntry fileEntry, byte[] fileData) throws DiskFullException Set the GEOS "tree" file data.- Throws:
DiskFullException
-
findFreeBlock
Locate a free block in the Volume Bitmap.- Throws:
DiskFullException
-
readVolumeBitMap
public byte[] readVolumeBitMap()Read the Volume Bit Map. -
writeVolumeBitMap
public void writeVolumeBitMap(byte[] data) Write the Volume Bit Map. -
isBlockFree
public boolean isBlockFree(byte[] data, int blockNumber) Determine if the specified block is free. -
setBlockFree
public void setBlockFree(byte[] data, int blockNumber) Set if the specified block is free. -
isBlockUsed
public boolean isBlockUsed(byte[] data, int blockNumber) Determine if the specified block is used. -
setBlockUsed
public void setBlockUsed(byte[] data, int blockNumber) Set if the specified block is free. -
format
public void format()Format the ProDOS volume.- Specified by:
formatin classFormattedDisk- See Also:
-
getLogicalDiskNumber
public int getLogicalDiskNumber()Returns the logical disk number. Returns a 0 to indicate no numbering.- Specified by:
getLogicalDiskNumberin classFormattedDisk
-
getSuggestedFilename
Returns a valid filename for the given filename. ProDOS filenames have a maximum length of 15 characters, must start with a character and may contain characters (A-Z), digits (0-9), or the period (.).- Specified by:
getSuggestedFilenamein classFormattedDisk
-
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.- Specified by:
getSuggestedFiletypein classFormattedDisk
-
getFiletype
Return the filetype of this file. This will be three characters, according to ProDOS - a "$xx" if unknown. -
getFiletype
Get the numerical filetype. -
fileTypeNeedsAddress
Utility method to indicate if this file type needs an address. -
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
-
needsAddress
Indicates if this filetype requires an address component.- Specified by:
needsAddressin 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- Throws:
DiskFullException
-
getVolumeHeader
-
createDirectory
Create a new DirectoryEntry.- Throws:
DiskFullException- See Also:
-
createDirectory
public DirectoryEntry createDirectory(ProdosCommonDirectoryHeader directory, String name) throws DiskFullException Create a new DirectoryEntry.- Throws:
DiskFullException
-
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
-