Class CpmFileEntry
- java.lang.Object
-
- com.webcodepro.applecommander.storage.os.cpm.CpmFileEntry
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL_RECORDS_FILLED_SIZE
The number of bytes used if all records in an extent are filled.static int
ALLOCATION_OFFSET
Beginning of block allocations.static int
ENTRY_LENGTH
The standard CP/M file entry length.static int
EXTENT_COUNTER_OFFSET
Offset to the extent counter (EX) field.static int
FILENAME_LENGTH
Filename length (excluding extension).static int
FILENAME_OFFSET
Offset to beginning of the filename.static int
FILETYPE_LENGTH
Filetype length.static int
FILETYPE_OFFSET
Offset to beginning of the filetype.static int
FILETYPE_T1_OFFSET
Offset to the filetype "T1" entry.static int
FILETYPE_T2_OFFSET
Offset to the filetype "T2" entry.static int
FILETYPE_T3_OFFSET
Offset to the filetype "T3" entry.static int
MAX_EXTENTS_PER_ENTRY
The maximum number of extents per file entry record.static int
RECORD_COUNT_OFFSET
Offset to the record count (RC) field.static java.lang.String[]
TEXT_FILETYPES
A short collection of known text-type files.static int
USER_NUMBER_OFFSET
The user number (UU) field is to distinguish multiple files with the same filename.
-
Constructor Summary
Constructors Constructor Description CpmFileEntry(CpmFormatDisk disk, int offset)
Construct a CP/M file entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOffset(int offset)
Add another directory offset to this file entry.boolean
canCompile()
Indicates that this filetype can be compiled.void
delete()
There appears to be no disk map involved, so deleting a file consists of writing a 0xe5 to the user number.protected int
findLargestExtent()
Locate the largest extent for this file.int
getAddress()
Get the address that this file loads at.int[]
getAllocations()
Answer with a list of blocks allocated to this file.int
getBlocksUsed()
Compute the number of blocks used.int
getExtentCounterLow(int entryNumber)
Read the extent number, low byte.java.util.List<java.lang.String>
getFileColumnData(int displayMode)
Get the standard file column header information.byte[]
getFileData()
Get file data.java.lang.String
getFilename()
Answer with the name of the file.java.lang.String
getFiletype()
Answer with the filetype.byte
getFileTypeT1(int entryNumber)
Read the file type T1 entry.byte
getFileTypeT2(int entryNumber)
Read the file type T2 entry.byte
getFileTypeT3(int entryNumber)
Read the file type T3 entry.FormattedDisk
getFormattedDisk()
Answer with the formatted disk.int
getMaximumFilenameLength()
Answer with the maximum filename length.int
getNumberOfRecordsUsed(int entryNumber)
Return the number of records used in this extent, low byte.int
getSize()
Compute the size of this file (in bytes).FileFilter
getSuggestedFilter()
Get the suggested FileFilter.int
getUserNumber(int entryNumber)
Return the user number (UU).boolean
isDeleted()
Indicates if this fileEntry is a deleted file.boolean
isDirectory()
Apple CP/M does not support directories.boolean
isEmpty()
Indicates if this is an empty file entry.boolean
isLocked()
Indicates if this file is locked.boolean
needsAddress()
Indicates if this filetype requires an address component.protected byte[]
readFileEntry(int number)
Read the fileEntry bytes from the disk image.void
setAddress(int address)
Set the address that this file loads at.void
setFileData(byte[] data)
Set file data.void
setFilename(java.lang.String filename)
Set the filename.void
setFiletype(java.lang.String filetype)
Set the filetype.void
setFileTypeT1(int entryNumber, int t1)
Write the file type T1 entry.void
setFileTypeT2(int entryNumber, int t2)
Write the file type T2 entry.void
setFileTypeT3(int entryNumber, int t3)
Write the file type T3 entry.void
setLocked(boolean lock)
Set the locked status.void
setUserNumber(int entryNumber, int userNumber)
Write the user number (UU).protected void
writeFileEntry(int number, byte[] entry)
Write the fileEntry bytes back to the disk image.
-
-
-
Field Detail
-
ENTRY_LENGTH
public static final int ENTRY_LENGTH
The standard CP/M file entry length.- See Also:
- Constant Field Values
-
MAX_EXTENTS_PER_ENTRY
public static final int MAX_EXTENTS_PER_ENTRY
The maximum number of extents per file entry record.- See Also:
- Constant Field Values
-
ALL_RECORDS_FILLED_SIZE
public static final int ALL_RECORDS_FILLED_SIZE
The number of bytes used if all records in an extent are filled. (MAX_EXTENTS_PER_ENTRY * CPM_SECTOR_SIZE)- See Also:
- Constant Field Values
-
USER_NUMBER_OFFSET
public static final int USER_NUMBER_OFFSET
The user number (UU) field is to distinguish multiple files with the same filename. This appears to be primarily with deleted files?- See Also:
- Constant Field Values
-
FILENAME_OFFSET
public static final int FILENAME_OFFSET
Offset to beginning of the filename.- See Also:
- Constant Field Values
-
FILENAME_LENGTH
public static final int FILENAME_LENGTH
Filename length (excluding extension).- See Also:
- Constant Field Values
-
FILETYPE_OFFSET
public static final int FILETYPE_OFFSET
Offset to beginning of the filetype.- See Also:
- Constant Field Values
-
FILETYPE_LENGTH
public static final int FILETYPE_LENGTH
Filetype length.- See Also:
- Constant Field Values
-
FILETYPE_T1_OFFSET
public static final int FILETYPE_T1_OFFSET
Offset to the filetype "T1" entry. Indicates read-only.- See Also:
- Constant Field Values
-
FILETYPE_T2_OFFSET
public static final int FILETYPE_T2_OFFSET
Offset to the filetype "T2" entry. Indicates system or hidden file.- See Also:
- Constant Field Values
-
FILETYPE_T3_OFFSET
public static final int FILETYPE_T3_OFFSET
Offset to the filetype "T3" entry. Backup bit (CP/M 3.1 and later).- See Also:
- Constant Field Values
-
EXTENT_COUNTER_OFFSET
public static final int EXTENT_COUNTER_OFFSET
Offset to the extent counter (EX) field.- See Also:
- Constant Field Values
-
RECORD_COUNT_OFFSET
public static final int RECORD_COUNT_OFFSET
Offset to the record count (RC) field.- See Also:
- Constant Field Values
-
ALLOCATION_OFFSET
public static final int ALLOCATION_OFFSET
Beginning of block allocations.- See Also:
- Constant Field Values
-
TEXT_FILETYPES
public static final java.lang.String[] TEXT_FILETYPES
A short collection of known text-type files.
-
-
Constructor Detail
-
CpmFileEntry
public CpmFileEntry(CpmFormatDisk disk, int offset)
Construct a CP/M file entry.
-
-
Method Detail
-
addOffset
public void addOffset(int offset)
Add another directory offset to this file entry.
-
readFileEntry
protected byte[] readFileEntry(int number)
Read the fileEntry bytes from the disk image.
-
writeFileEntry
protected void writeFileEntry(int number, byte[] entry)
Write the fileEntry bytes back to the disk image.
-
getFilename
public java.lang.String getFilename()
Answer with the name of the file.- Specified by:
getFilename
in interfaceFileEntry
- See Also:
FileEntry.getFilename()
-
setFilename
public void setFilename(java.lang.String filename)
Set the filename. Note that this assumes the file extension is completely separate and does not validate characters that are being set!- Specified by:
setFilename
in interfaceFileEntry
- See Also:
FileEntry.setFilename(java.lang.String)
-
getFiletype
public java.lang.String getFiletype()
Answer with the filetype.- Specified by:
getFiletype
in interfaceFileEntry
- See Also:
FileEntry.getFiletype()
-
setFiletype
public void setFiletype(java.lang.String filetype)
Set the filetype. Note that the highbits need to be preserved.- Specified by:
setFiletype
in interfaceFileEntry
- See Also:
FileEntry.setFiletype(java.lang.String)
-
isLocked
public boolean isLocked()
Indicates if this file is locked.- Specified by:
isLocked
in interfaceFileEntry
- See Also:
FileEntry.isLocked()
-
getFileTypeT1
public byte getFileTypeT1(int entryNumber)
Read the file type T1 entry. This is the 1st character of the file type and the high bit indicates read-only.
-
setFileTypeT1
public void setFileTypeT1(int entryNumber, int t1)
Write the file type T1 entry.
-
getFileTypeT2
public byte getFileTypeT2(int entryNumber)
Read the file type T2 entry. This is the 2nd character of the file type and the high bit indicates a system or hidden file.
-
setFileTypeT2
public void setFileTypeT2(int entryNumber, int t2)
Write the file type T2 entry.
-
getFileTypeT3
public byte getFileTypeT3(int entryNumber)
Read the file type T3 entry. This is the 3rd character of the file type and the high bit is the backup bit (CP/M 3.1 and later).
-
setFileTypeT3
public void setFileTypeT3(int entryNumber, int t3)
Write the file type T3 entry.
-
setLocked
public void setLocked(boolean lock)
Set the locked status. This is interpreted as read-only.- Specified by:
setLocked
in interfaceFileEntry
- See Also:
FileEntry.setLocked(boolean)
-
getExtentCounterLow
public int getExtentCounterLow(int entryNumber)
Read the extent number, low byte.
-
getSize
public int getSize()
Compute the size of this file (in bytes).- Specified by:
getSize
in interfaceFileEntry
- See Also:
FileEntry.getSize()
-
findLargestExtent
protected int findLargestExtent()
Locate the largest extent for this file.
-
getBlocksUsed
public int getBlocksUsed()
Compute the number of blocks used.
-
getNumberOfRecordsUsed
public int getNumberOfRecordsUsed(int entryNumber)
Return the number of records used in this extent, low byte. 1 record = 128 bytes.
-
isDirectory
public boolean isDirectory()
Apple CP/M does not support directories.- Specified by:
isDirectory
in interfaceFileEntry
- See Also:
FileEntry.isDirectory()
-
isDeleted
public boolean isDeleted()
Indicates if this fileEntry is a deleted file.- Specified by:
isDeleted
in interfaceFileEntry
- See Also:
FileEntry.isDeleted()
-
getUserNumber
public int getUserNumber(int entryNumber)
Return the user number (UU). 0-15 on Apple CP/M (can range to 31 on some systems). The user number allows multiple files with the same name to coexist on the disk. Apparently, this is used in conjunction with deleted files.
-
setUserNumber
public void setUserNumber(int entryNumber, int userNumber)
Write the user number (UU).
-
delete
public void delete()
There appears to be no disk map involved, so deleting a file consists of writing a 0xe5 to the user number.- Specified by:
delete
in interfaceFileEntry
- See Also:
FileEntry.delete()
-
getFileColumnData
public java.util.List<java.lang.String> getFileColumnData(int displayMode)
Get the standard file column header information. This default implementation is intended only for standard mode. displayMode is specified in FormattedDisk.- Specified by:
getFileColumnData
in interfaceFileEntry
-
getFileData
public byte[] getFileData()
Get file data. This handles any operating-system specific issues.- Specified by:
getFileData
in interfaceFileEntry
- See Also:
FileEntry.getFileData()
-
setFileData
public void setFileData(byte[] data) throws DiskFullException
Set file data. This, essentially, is saving data to disk using this file entry.- Specified by:
setFileData
in interfaceFileEntry
- Throws:
DiskFullException
- See Also:
FileEntry.setFileData(byte[])
-
getSuggestedFilter
public FileFilter getSuggestedFilter()
Get the suggested FileFilter. This is a guess based on what appears to be text-based files.- Specified by:
getSuggestedFilter
in interfaceFileEntry
- See Also:
FileEntry.getSuggestedFilter()
-
getFormattedDisk
public FormattedDisk getFormattedDisk()
Answer with the formatted disk.- Specified by:
getFormattedDisk
in interfaceFileEntry
- See Also:
FileEntry.getFormattedDisk()
-
getMaximumFilenameLength
public int getMaximumFilenameLength()
Answer with the maximum filename length.- Specified by:
getMaximumFilenameLength
in interfaceFileEntry
- See Also:
FileEntry.getMaximumFilenameLength()
-
needsAddress
public boolean needsAddress()
Indicates if this filetype requires an address component.- Specified by:
needsAddress
in interfaceFileEntry
- See Also:
FileEntry.needsAddress()
-
setAddress
public void setAddress(int address)
Set the address that this file loads at.- Specified by:
setAddress
in interfaceFileEntry
- See Also:
FileEntry.setAddress(int)
-
getAddress
public int getAddress()
Get the address that this file loads at.- Specified by:
getAddress
in interfaceFileEntry
-
canCompile
public boolean canCompile()
Indicates that this filetype can be compiled. AppleCommander cannot do much with CP/M files.- Specified by:
canCompile
in interfaceFileEntry
- See Also:
FileEntry.canCompile()
-
isEmpty
public boolean isEmpty()
Indicates if this is an empty file entry. An empty file entry contains all 0xE5.
-
getAllocations
public int[] getAllocations()
Answer with a list of blocks allocated to this file.
-
-