Package drivers.nxfa

Class QemuFileheader

java.lang.Object
drivers.nxfa.QemuFileheader
All Implemented Interfaces:
XfaFileheader

public class QemuFileheader extends Object implements 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 Details

    • QemuFileheader

      public QemuFileheader(File f, String filename, FileChannel inoutChannel) throws IOException
      Creates the object either from an existing java.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

      public int readFileheader(MC68000Cpu cpu, int position, int bufflen)
      "Reads" the file header into the SMSQE buffer.
      Specified by:
      readFileheader in interface XfaFileheader
      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

      public int writeFileHeader(MC68000Cpu cpu, int position)
      Writes the first 14 bytes of the fileheader from SMSQE to the SFA header.
      Specified by:
      writeFileHeader in interface XfaFileheader
      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

      public boolean flushHeader(FileChannel inoutChannel, boolean setDate)
      Actually writes the header to the file. !!!! This is always done (if possible!), contrary to what Qemulator does. !!!!
      Specified by:
      flushHeader in interface XfaFileheader
      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 interface XfaFileheader
      Returns:
      the offset as int.
      See Also:
    • getSMSQEFilename

      public String getSMSQEFilename()
      Gets the (SMSQE) filename from the header.
      Specified by:
      getSMSQEFilename in interface XfaFileheader
      Returns:
      the filename as a Java String.
    • setSMSQEFilename

      public void setSMSQEFilename(String filename)
      Sets the (SMSQE) filename in the header.
      Specified by:
      setSMSQEFilename in interface XfaFileheader
      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 interface XfaFileheader
      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 interface XfaFileheader
      Parameters:
      whatDate - what date do we want : 0 update date 2 : backup date
      dateToSet - 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 interface XfaFileheader
      Returns:
      the file version
    • setVersion

      public void setVersion(int version)
      Sets the version in the header.
      Specified by:
      setVersion in interface XfaFileheader
      Parameters:
      version - the version (a word) to set.
    • setFileDates

      public void setFileDates(File f)
      Sets the date of the file (in milliseconds)
      Specified by:
      setFileDates in interface XfaFileheader
      Parameters:
      f - the file for which the date should be set.
    • isExecutable

      public boolean isExecutable()
      Checks whether file is executable.
      Specified by:
      isExecutable in interface XfaFileheader
      Returns:
      true if file is executable.
    • getDataSpace

      public int getDataSpace()
      Gets the dataspace.
      Specified by:
      getDataSpace in interface XfaFileheader
      Returns:
      the dataspace if any, or 0 if none