public class MemDrive extends WinDrive
Except for specific methods, this is a clone on the WinDrive class.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_FILESIZE |
clusterSize, cpu, driveFAT, driveName, driveNumber, driver, fatClusterChain, fileNumber, flock, ioChannel, LOWER_CASE, mainDir, MAX_FILES_OPEN, QWA_CYLD, QWA_FCYL, QWA_FGRP, QWA_FREE, QWA_FSCT, QWA_GMAP, QWA_IDEN, QWA_INTL, QWA_NAME, QWA_NGRP, QWA_NMAP, QWA_PARK, QWA_RLEN, QWA_ROOT, QWA_SCTG, QWA_SCTM, QWA_SCTT, QWA_SPR0, QWA_TRKC, QWA_UCHK, raFile, readOnly, specialFileIsOpen, warnings
Constructor and Description |
---|
MemDrive(MC68000Cpu cpu,
java.lang.String driveName,
MemDriver driver,
int number,
Warnings warn)
Creates the object.
|
Modifier and Type | Method and Description |
---|---|
int |
readBytes(int nbrOfBytes,
java.nio.ByteBuffer buffer,
long position)
Reads bytes at a certain position in the drive to a buffer.
|
java.nio.ByteBuffer |
readFile(int fileLength,
int cluster,
java.util.ArrayList<java.lang.Integer> clusterchain)
Creates a ByteBuffer (for a file) and reads the file into it.
|
void |
writeBack(java.lang.String driveName)
Writes the drive back to a native file
|
int |
writeBytes(int nbrOfBytes,
java.nio.ByteBuffer buffer,
long position,
int startInBuffer)
Writes bytes from a certain position in a buffer to a certain position in the drive.
|
void |
writeFile(java.nio.ByteBuffer fileBuffer,
java.util.ArrayList<java.lang.Integer> clusterchain)
This writes an entire file in a byte buffer back to the drive.
|
void |
writePartOfFile(java.nio.ByteBuffer fileBuffer,
java.util.ArrayList<java.lang.Integer> clusterchain,
int start,
int bytesToWrite)
This writes a part of byte buffer back to the drive.
|
allocateClusters, changeParentDir, checkSector, closeAllFiles, closeFile, convert2SMSQELowerCase, flush, freeClusters, getClusterSize, getDrivename, getIntFromFAT, increaseCapacity, isReadOnly, openFile, setCpu, setRootDirLength, specialFileClosed, trap3OK, truncateFile, unuse
public static final int MAX_FILESIZE
public MemDrive(MC68000Cpu cpu, java.lang.String driveName, MemDriver driver, int number, Warnings warn) throws java.io.FileNotFoundException, java.io.IOException, java.lang.ArrayIndexOutOfBoundsException, java.net.ProtocolException, DoNothingException, IncorrectFiletypeException
cpu
- the cpu used.driveName
- the name of the qxl.win file on the native file system.driver
- the driver having created this object.number
- my driveNbr as ASCII!.warn
- object with warning flags.java.io.FileNotFoundException
- the qxl.win file isn't foundjava.io.IOException
- any IO exception reading the FAT / main dirjava.lang.ArrayIndexOutOfBoundsException
- a wrong FAT cluster number was givenjava.net.ProtocolException
- if the main dir couldn't be read.DoNothingException
- if this is a drive with a wrong FAT and user doesn't want me to (try to) fix it.IncorrectFiletypeException
- if this is not a valid qlwa file.public java.nio.ByteBuffer readFile(int fileLength, int cluster, java.util.ArrayList<java.lang.Integer> clusterchain)
readFile
in class WinDrive
fileLength
- the length of the file (should include the length of the file header).cluster
- the first cluster of the file (index into the FAT).clusterchain
- - the empty cluster chain, will be filled in here.null
if problem. Attention : the size of the buffer will most
likely be bigger than the size of the file : the size of the buffer is increased to be a multiple of the clusterSize.
This should correspond to the number of clusters occupied by the file.public void writeFile(java.nio.ByteBuffer fileBuffer, java.util.ArrayList<java.lang.Integer> clusterchain) throws java.io.IOException
public void writePartOfFile(java.nio.ByteBuffer fileBuffer, java.util.ArrayList<java.lang.Integer> clusterchain, int start, int bytesToWrite) throws java.io.IOException
writePartOfFile
in class WinDrive
fileBuffer
- the ByteBuffer containing the file. The capacity of the buffer may be bigger than the true filesize.clusterchain
- the first cluster of the file.start
- where in the buffer to start writing.bytesToWrite
- how many bytes must be written.java.io.IOException
- any i/o exception from the java i/o operations.public int readBytes(int nbrOfBytes, java.nio.ByteBuffer buffer, long position)
readBytes
in class WinDrive
nbrOfBytes
- how many bytes to read.buffer
- where to read the bytes to - this buffer must be at least nbrOfBytes long. The bytes are read to the start of the buffer.position
- where to read from in the drive.public int writeBytes(int nbrOfBytes, java.nio.ByteBuffer buffer, long position, int startInBuffer)
writeBytes
in class WinDrive
nbrOfBytes
- how many bytes to write.buffer
- where to read the bytes to - this buffer must be at least nbrOfBytes long. The bytes are taken from the start of the bufferposition
- where to write to in the drive.startInBuffer
- where in the buffer to start taking the bytes to wirite from.public void writeBack(java.lang.String driveName)
driveName
- the name of the native file.