public class WinDir extends WinFile
WinDriver.HEADER_LENGTH
bytes long. The first entry in the directory contains rubbish,
as that would be the file header of this directory (file).
The content (structure) of the file entry/header is explained below but it contains at least the length of the file and its name. The length of the file in the directory entry comprises that of the file header.
In a directory entry, if a file has a length of 0, then this is an empty entry in the directory, since a valid file always has a length of, at least,
WinDriver.HEADER_LENGTH
bytes (length of the header).
When the fileheader is returned to SMSQE, WinDriver.HEADER_LENGTH
bytes are deducted from the length of the file as contained in the
directory header to make the "real" length of the file as SMSQE sees it.
Creating a directory should go as follows : open file with opentype #2. call trap #3 with $4d, close file.
Directories may grow, but they never shrink (unless, if entirely empty, they are totally deleted).
Modifier and Type | Field and Description |
---|---|
static int |
HDR_ACCS |
static int |
HDR_BKUP |
static int |
hdr_data |
static int |
HDR_DATE |
static int |
hdr_end |
static int |
HDR_FLEN |
static int |
HDR_FLID |
static int |
hdr_info |
static int |
HDR_NAME |
static int |
HDR_TYPE |
static int |
HDR_VERS |
static int |
hdr_xtra |
static int |
HDRLEN |
static int |
HDRNAME |
static int |
HDRNAMEL |
static int |
HDRNMLN |
static int |
hdrSet |
static int |
hdrtDir |
static int |
hdrtExe |
static int |
hdrtLdr |
static int |
hdrtRel |
buffer, clusterchain, dir, dirChanged, drive, fileChanged, filePosition, fileSize, index, isDir, mapChanged, readOnly, setDate
Constructor and Description |
---|
WinDir(WinDrive drive,
WinDir parentDir,
int index,
java.nio.ByteBuffer buf,
java.util.ArrayList<java.lang.Integer> cchain,
byte[] name,
byte[] normalizedName)
This creates the directory object.
|
Modifier and Type | Method and Description |
---|---|
void |
addToList(WinDir toAdd)
Add a dir to my dir list.
|
int |
checkFile(boolean[] flags,
byte[] fname)
This checks whether a file of that name exists in this dir.
|
void |
closeFile(int entry,
boolean dirChanged,
boolean setDate)
Does what is necessary when a file is closed: set file size, date etc...
|
int |
deleteFile(int entry)
Deletes a file from this directory (and thus from the disk).
|
boolean |
fileIsDir(int index)
Checks whether the file at (index) is a directory.
|
int |
findFreeEntryInDir()
Finds the first free entry in my buffer.
|
WinDir |
findInDirs(byte[] fname)
Finds out whether a file belongs or would belong in this dir or any of its subdirs.
|
java.nio.ByteBuffer |
getDirBuffer()
Gets the ByteBuffer containing the data in this dir.
|
int |
getFileDate(int whatDate)
Gets the date of the file.
|
int |
getFileLength(int index)
Gets the length of a file at (index).
|
int |
getFileVersion(int entry)
Gets the version of the file.
|
byte[] |
getName()
Gets the name of this directory.
|
byte[] |
getUncasedName()
Gets the lower cased name of this file.
|
boolean |
makeDirectory(int entry,
java.util.ArrayList<java.lang.Integer> cchain,
java.nio.ByteBuffer buf)
This converts an existing file contained in a parent directory (this object) into a subdirectory thereof.
|
WinFile |
openFile(int entry,
byte[] filename,
int openType,
MC68000Cpu cpu)
Opens a file.
|
void |
removeFromList(WinDir toRemove)
Remove a dir from my dir list.
|
void |
renameFile(WinDir oldDir,
WinFile wFile,
byte[] fname)
Renames/moves a file from the old directory to this new one.
|
void |
setFileDate(int entry,
int mdate)
Sets the date of the file.
|
void |
setFileHeader(int entry,
MC68000Cpu cpu,
int length)
Sets the header for a file (always 14 bytes).
|
void |
setFileVersion(int entry,
int version)
Sets the version of the file.
|
void |
setInHeader(int offset,
int longword)
Sets a long word in a header.
|
close, getDir, getIndex, handleTrap3, setDir, setDirAndFatChanged, setDirStatus, setIndex, writeFile
public static final int HDR_FLEN
public static final int HDR_ACCS
public static final int HDR_TYPE
public static final int hdrtExe
public static final int hdrtRel
public static final int hdrtLdr
public static final int hdrtDir
public static final int hdr_info
public static final int hdr_data
public static final int hdr_xtra
public static final int HDR_NAME
public static final int HDRNAMEL
public static final int HDRNAME
public static final int HDRNMLN
public static final int HDR_DATE
public static final int HDR_VERS
public static final int HDR_FLID
public static final int HDR_BKUP
public static final int hdr_end
public static final int hdrSet
public static final int HDRLEN
public WinDir(WinDrive drive, WinDir parentDir, int index, java.nio.ByteBuffer buf, java.util.ArrayList<java.lang.Integer> cchain, byte[] name, byte[] normalizedName)
drive
- the drive on which this dir lies.parentDir
- the dir containing this dir, will be null if this is the root directory.index
- index into the parent dir (offset from start of parent dir buffer to my header). Will be 0 isf this is the root directory.buf
- the ByteBuffer containg this entire dir.cchain
- the clusterchain for this directory.name
- the name for this dir.normalizedName
- the name of this dir in SMSQE lower case.public WinFile openFile(int entry, byte[] filename, int openType, MC68000Cpu cpu)
entry
- the index into the buffer of the file to open - 0 if the file doesn't exist yet.filename
- the name of the file as it appears in the open call. The length will be 0 for the main directory.openType
- the type of open wished.cpu
- the cpu to be used.public void closeFile(int entry, boolean dirChanged, boolean setDate)
entry
- entry in this bufferdirChanged
- = true
if this dir should save itself to disk since something in it has changed.setDate
- set to true
if the file date should be set in the file's header (which it shouldn't if the file is read only).public int deleteFile(int entry)
entry
- the entry to delete. If this is 0, the dir is supposed to delete itself.public boolean makeDirectory(int entry, java.util.ArrayList<java.lang.Integer> cchain, java.nio.ByteBuffer buf)
This is NOT checked here again!!!!
entry
- where this file header is in the parent dir's buffer.cchain
- the file's clusterchain - this might have to be increased.buf
- the file's buffer (i.e. the file's data on the disk) -I might have to increase this.false
if error, true
if conversion file to dir went OK.public void renameFile(WinDir oldDir, WinFile wFile, byte[] fname)
oldDir
- the directory currently holding this file.wFile
- the file to be renamed.fname
- the new name of the file.public void setFileHeader(int entry, MC68000Cpu cpu, int length)
entry
- where in the dir buffer is the header to be set.cpu
- the SMSQ/E CPU - A1 points to the data for the file header. MUST BE AT AN EVEN ADDRESS!!!!!!length
- the length of the file.public void setInHeader(int offset, int longword)
offset
- where to set the element (i.e. index+entry in header).longword
- what to set.public boolean fileIsDir(int index)
index
- index into this buffer, where the file to check lies (should be multiple of Windriver.HEADER_LENGTH).true
if this is a (sub)directory, else false
public int getFileLength(int index)
index
- where the file lies in the directory.public int getFileVersion(int entry)
entry
- where the file lies in the directory.public void setFileVersion(int entry, int version)
entry
- where the file lies in the directory.version
- the file version to set.public int getFileDate(int whatDate)
whatDate
- what date to get (i.e. index+date to get -upate or backup date).public void setFileDate(int entry, int mdate)
entry
- what date to set (i.e. index+date to get -upate or backup date).mdate
- the date in QL format.public WinDir findInDirs(byte[] fname)
fname
- the lower cased name of the file.public int checkFile(boolean[] flags, byte[] fname)
fname
- : the uncased name of the file (SMSQE lower case)flags
- a (return) array of booleans which will be filled in this method :
[0] true if file exists in this dir.
[1] true if file is a dir.
[2] true if file can't be written to.
[3] true if file has channels open to it.public int findFreeEntryInDir()
public void addToList(WinDir toAdd)
toAdd
- the WinDir to add.public void removeFromList(WinDir toRemove)
toRemove
- the WinDir to remove.public byte[] getName()
public byte[] getUncasedName()
public java.nio.ByteBuffer getDirBuffer()