Package drivers.win
Class WinFile
java.lang.Object
drivers.win.WinFile
- Direct Known Subclasses:
WinDir
,WinSpecialFile
This is the class representing one file on a QXL.WIN device.
In view of the small file sizes for SMSQE files, each WinFile maintains a ByteBuffer containing the entire contents of the SMSQE file.
The limit of this buffer must always be set to its capacity on entry/exit to any routine.
The position should correspond to the current file position (+ header).
There are 4 flags:
- fileChanged : if true, something has changed in the file. It should be written out when closed/flushed.
- dirChanged : if true, something has changed in the directory containing this file. It should be written back to the drive.
- mapChanged : the drive FAT was changed (e.g. a new cluster allocated to the file). Most changes will be written back during the file close routine.
- setDate : if true, the file date must be set to the current date when the file is closed.
A file object is created whenever an SMSQE file is "opened". The file position is set to point just after the header. The file object is called upon when:
- any i/o operation is to be made.
- the file is to be closed again.
The file MAY also be a directory that is opened via a normal open read-only call. If filePosition=fileSize the we're at EOF. Each file has a "clusterchain", an arraylist with the number of the cluster for a part of the file.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ByteBuffer
protected WinDir
protected boolean
protected WinDrive
protected boolean
protected int
protected int
protected int
protected boolean
protected boolean
protected boolean
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this file : writes the file to disk if need be.getDir()
Gets the directory this file is in.int
getIndex()
Gets the file index.int
handleTrap3
(int trapKey, MC68000Cpu cpu) This dispatches the file I/O routines (=SMSQE TRAP#3 routines).void
Sets the directory this file is in.void
Show that the directory and the FAT must have changed.void
setDirStatus
(boolean dirstat) Sets whether this file is a dir or not.void
setIndex
(int newIndex) Sets the file index.void
writeFile
(int start, int nbr) Writes all or part of this file back to the disk.
-
Field Details
-
filePosition
protected int filePosition -
fileSize
protected int fileSize -
buffer
-
index
protected int index -
dir
-
drive
-
readOnly
protected boolean readOnly -
isDir
protected boolean isDir -
clusterchain
-
fileChanged
protected boolean fileChanged -
dirChanged
protected boolean dirChanged -
mapChanged
protected boolean mapChanged -
setDate
protected boolean setDate
-
-
Constructor Details
-
WinFile
public WinFile(WinDrive drive, WinDir dir, int index, boolean readOnly, ByteBuffer buf, ArrayList<Integer> cchain) Creates the object.- Parameters:
drive
- the WinDrive the file is on.dir
- the directory where this file is in (null if root dir)index
- index into the buffer of the dir containing this file (if file is not the root dir) (the index points to the file header for this file).readOnly
- set to true of this file is opened for read only access.buf
- the buffer to be used by this file.cchain
- the clusterchain for this object.
-
WinFile
public WinFile()Do not call this way of opening for real!!!!!.
-
-
Method Details
-
close
public void close()Closes this file : writes the file to disk if need be. Also possibly causes the dir and the drive to write themselves out to disk. -
handleTrap3
This dispatches the file I/O routines (=SMSQE TRAP#3 routines). NB : case $4a (rename file) is handled by the drive object directly, not by the file, same for $45 (info about medium) and $4f (extended info) In all cases, the timeout (in D3) is totally ignored - all operations will always take place in what the cpu thinks is no time.- Parameters:
trapKey
- what kind of trap#3 are we dealing with?cpu
- the current CPU doing the call.- Returns:
- SMSQE error/success code. NOTE: the switch cases all return immediately with a success/error code.
-
writeFile
public void writeFile(int start, int nbr) Writes all or part of this file back to the disk.- Parameters:
start
- where to start writing from (index into the buffer).nbr
- how many bytes to write. Note: if both start and nbr are 0, the entire file is written.
-
setDirStatus
public void setDirStatus(boolean dirstat) Sets whether this file is a dir or not.- Parameters:
dirstat
- is true if this file is to be a dir.
-
getDir
Gets the directory this file is in.- Returns:
- the directory this file is in, may be null if this is the main dir.
-
setDir
Sets the directory this file is in.- Parameters:
newDir
- the new directory this file is in.
-
getIndex
public int getIndex()Gets the file index.- Returns:
- the index , i.e. where in its directory this file lies.
-
setIndex
public void setIndex(int newIndex) Sets the file index.- Parameters:
newIndex
- the new index into the directory.
-
setDirAndFatChanged
public void setDirAndFatChanged()Show that the directory and the FAT must have changed.
-