Package drivers.nxfa

Class SfaFileheader

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

public class SfaFileheader extends Object implements XfaFileheader
Creates an SMSQE fileheader for SFA files.
  • Constructor Details

    • SfaFileheader

      public SfaFileheader(File f, String filename, FileChannel inoutChannel, int lengthIfDir) throws IOException
      Creates the object either from an existing java.io.File, or a newly created one.
      Parameters:
      f - the file.
      filename - the filename.
      inoutChannel - a channel for reading the existing header.
      lengthIfDir - length if file if it is a directory.
      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.
      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:
      true if the file dates should be set after closing the file
    • getOffset

      public int getOffset()
      Gets the header offset.
      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 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!!!!!!!!!!
    • 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