Package drivers.nxfa
Class QemuFileheader
java.lang.Object
drivers.nxfa.QemuFileheader
- All Implemented Interfaces:
XfaFileheader
Creates an SMSQE fileheader for QEMU or SFA files on SFA devices.
The length of the file in the header is a length WITHOUT the length of the header.
------------ According to Daniele Terdina ------ :
QL files have a special piece of information associated with them, called the ‘QDOS file header’.
The header stores such information as the file name and whether the file is an executable program.
Q-emuLator stores part of the header at the beginning of files. The header is present
only when it is useful, ie. only if it contains non-default information.
The header has the following format:
OFFSET LENGTH(bytes) CONTENT
0 18 “]!QDOS File Header“
18 1 0 (reserved)
19 1 total length_of_header, in 16 bit words
20 length_of_header*2-20 QDOS INFO
The first 18 bytes are there to detect whether the header is present (ID string).
The headers Q-emuLator supports can be 30 bytes or 44 bytes long (the value of the
corresponding byte at offset 19 is either 15 or 22). In the first case, there are 10 bytes with the values
present in bytes 4 to 13 of the 64 bytes QDOS header. In the second case the same piece of
information is followed by 14 bytes containing a microdrive sector header, useful for emulating
microdrive protection schemes. Additional header information (file length, name, dates) is obtained
directly from the file through the host file system.
--------------------------------------
However, SMSQmulator wil ALWAYS create a "special" file header on SFA devices.
-
Constructor Summary
ConstructorsConstructorDescriptionQemuFileheader
(File f, String filename, FileChannel inoutChannel) Creates the object either from an existingjava.io.File
, or a newly created one. -
Method Summary
Modifier and TypeMethodDescriptionboolean
flushHeader
(FileChannel inoutChannel, boolean setDate) Actually writes the header to the file.int
Gets the dataspace.int
getDate
(int whatDate) Gets the date of the file from the header.int
Gets the header offset from beginning of native file to beginning of QL fileGets the (SMSQE) filename from the header.int
Gets the version of the file from the header.boolean
Checks whether file is executable.int
readFileheader
(MC68000Cpu cpu, int position, int bufflen) "Reads" the file header into the SMSQE buffer.void
setDate
(int whatDate, int dateToSet) Sets the date in the header.void
setFileDates
(File f) Sets the date of the file (in milliseconds)void
setSMSQEFilename
(String filename) Sets the (SMSQE) filename in the header.void
setVersion
(int version) Sets the version in the header.int
writeFileHeader
(MC68000Cpu cpu, int position) Writes the first 14 bytes of the fileheader from SMSQE to the SFA header.
-
Constructor Details
-
QemuFileheader
Creates the object either from an existingjava.io.File
, or a newly created one.- Parameters:
f
- the file fir which the header is to be created.filename
- the filename.inoutChannel
- a channel for reading the existing header.- Throws:
IOException
- from java io operations.
-
-
Method Details
-
readFileheader
"Reads" the file header into the SMSQE buffer.- Specified by:
readFileheader
in interfaceXfaFileheader
- Parameters:
cpu
- the cpu with the memory.position
- where in that memory the header should be written.bufflen
- how many bytes to write.- Returns:
- nbr of bytes read
- See Also:
-
writeFileHeader
Writes the first 14 bytes of the fileheader from SMSQE to the SFA header.- Specified by:
writeFileHeader
in interfaceXfaFileheader
- Parameters:
cpu
- the cpu with the memory from where to read the header.position
- the mem position in smsqe's memory map.- Returns:
- always 14 = nbr of bytes written.
- See Also:
-
flushHeader
Actually writes the header to the file. !!!! This is always done (if possible!), contrary to what Qemulator does. !!!!- Specified by:
flushHeader
in interfaceXfaFileheader
- Parameters:
inoutChannel
- The channel to write to.setDate
- = true if the date should be set to that of the channel's closing.- Returns:
- status of this.dateChanged
-
getOffset
public int getOffset()Gets the header offset from beginning of native file to beginning of QL file- Specified by:
getOffset
in interfaceXfaFileheader
- Returns:
- the offset as int.
- See Also:
-
getSMSQEFilename
Gets the (SMSQE) filename from the header.- Specified by:
getSMSQEFilename
in interfaceXfaFileheader
- Returns:
- the filename as a Java
String
.
-
setSMSQEFilename
Sets the (SMSQE) filename in the header.- Specified by:
setSMSQEFilename
in interfaceXfaFileheader
- Parameters:
filename
- the name to set.
-
getDate
public int getDate(int whatDate) Gets the date of the file from the header.- Specified by:
getDate
in interfaceXfaFileheader
- Parameters:
whatDate
- what date do we want : 0 update date 2 : backup date- Returns:
- the date of the file in smsqe format (date and time in seconds as of 1.1.1961.
-
setDate
public void setDate(int whatDate, int dateToSet) Sets the date in the header.- Specified by:
setDate
in interfaceXfaFileheader
- Parameters:
whatDate
- what date do we want : 0 update date 2 : backup datedateToSet
- the date to set as an SMSQE date (date and time in seconds as of 1.1.1961).. Contrary to the normal documentation, this will NOT set the backup date for a read only file!!!!!!!!!!
-
getVersion
public int getVersion()Gets the version of the file from the header.- Specified by:
getVersion
in interfaceXfaFileheader
- Returns:
- the file version
-
setVersion
public void setVersion(int version) Sets the version in the header.- Specified by:
setVersion
in interfaceXfaFileheader
- Parameters:
version
- the version (a word) to set.
-
setFileDates
Sets the date of the file (in milliseconds)- Specified by:
setFileDates
in interfaceXfaFileheader
- Parameters:
f
- the file for which the date should be set.
-
isExecutable
public boolean isExecutable()Checks whether file is executable.- Specified by:
isExecutable
in interfaceXfaFileheader
- Returns:
- true if file is executable.
-
getDataSpace
public int getDataSpace()Gets the dataspace.- Specified by:
getDataSpace
in interfaceXfaFileheader
- Returns:
- the dataspace if any, or 0 if none
-