removed buffer parameter

This commit is contained in:
Denis Molony 2021-05-04 07:24:08 +10:00
parent 032da321c3
commit ccbfc47a66
7 changed files with 23 additions and 38 deletions

View File

@ -30,11 +30,11 @@ public class DirectoryHeader
int fileCount;
// ---------------------------------------------------------------------------------//
public DirectoryHeader (ProdosDisk disk, byte[] buffer, int ptr)
public DirectoryHeader (ProdosDisk disk, int ptr)
// ---------------------------------------------------------------------------------//
{
this.disk = disk;
this.buffer = buffer;
this.buffer = disk.getBuffer ();
this.ptr = ptr;
}
@ -91,7 +91,7 @@ public class DirectoryHeader
int nameLength = buffer[ptr] & 0x0F;
if (nameLength != 0 && storageType < 0x0E)
{
FileEntry fileEntry = new FileEntry (disk, buffer, ptr);
FileEntry fileEntry = new FileEntry (disk, ptr);
fileEntry.read ();
System.out.println (fileEntry.toText ());
}

View File

@ -7,20 +7,16 @@ public class ExtendedKeyBlock
// -----------------------------------------------------------------------------------//
{
private final ProdosDisk disk;
private final byte[] buffer;
private final int ptr;
// int blockNo;
MiniEntry dataFork;
MiniEntry resourceFork;
// ---------------------------------------------------------------------------------//
public ExtendedKeyBlock (ProdosDisk disk, byte[] buffer, int ptr)
public ExtendedKeyBlock (ProdosDisk disk, int ptr)
// ---------------------------------------------------------------------------------//
{
this.disk = disk;
this.buffer = buffer;
this.ptr = ptr;
}
@ -52,10 +48,10 @@ public class ExtendedKeyBlock
// ---------------------------------------------------------------------------------//
{
if (dataFork != null) // else zero buffer??
dataFork.write (buffer, ptr);
dataFork.write (disk.getBuffer (), ptr);
if (resourceFork != null)
resourceFork.write (buffer, ptr + 0x100);
resourceFork.write (disk.getBuffer (), ptr + 0x100);
}
// ---------------------------------------------------------------------------------//

View File

@ -35,11 +35,11 @@ public class FileEntry
int headerPointer;
// ---------------------------------------------------------------------------------//
public FileEntry (ProdosDisk disk, byte[] buffer, int ptr)
public FileEntry (ProdosDisk disk, int ptr)
// ---------------------------------------------------------------------------------//
{
this.disk = disk;
this.buffer = buffer;
this.buffer = disk.getBuffer ();
this.ptr = ptr;
}

View File

@ -21,11 +21,11 @@ public class FileWriter
int eof;
// ---------------------------------------------------------------------------------//
FileWriter (ProdosDisk disk, byte[] buffer)
FileWriter (ProdosDisk disk)
// ---------------------------------------------------------------------------------//
{
this.disk = disk;
this.buffer = buffer;
this.buffer = disk.getBuffer ();
}
// ---------------------------------------------------------------------------------//

View File

@ -97,7 +97,7 @@ public class ProdosDisk
if (i == 0)
{
volumeDirectoryHeader = new VolumeDirectoryHeader (this, buffer, ptr + 4);
volumeDirectoryHeader = new VolumeDirectoryHeader (this, ptr + 4);
volumeDirectoryHeader.fileName = volumeName;
volumeDirectoryHeader.totalBlocks = maxBlocks;
volumeDirectoryHeader.creationDate = LocalDateTime.now ();
@ -187,7 +187,7 @@ public class ProdosDisk
fileEntry.creationDate = created;
fileEntry.modifiedDate = modified;
FileWriter fileWriter = new FileWriter (this, buffer);
FileWriter fileWriter = new FileWriter (this);
fileWriter.writeFile (dataBuffer, dataBuffer.length);
fileEntry.storageType = fileWriter.storageType;
@ -209,13 +209,12 @@ public class ProdosDisk
throws DiskFullException
// ---------------------------------------------------------------------------------//
{
FileWriter fileWriter = new FileWriter (this, buffer); // create dummy FileEntry
FileWriter fileWriter = new FileWriter (this); // create resource fork
fileWriter.writeFile (dataBuffer, eof);
int blockNo = allocateNextBlock ();
ExtendedKeyBlock extendedKeyBlock =
new ExtendedKeyBlock (this, buffer, blockNo * BLOCK_SIZE);
ExtendedKeyBlock extendedKeyBlock = new ExtendedKeyBlock (this, blockNo * BLOCK_SIZE);
extendedKeyBlock.addMiniEntry (1, fileEntry.storageType, fileEntry.keyPointer,
fileEntry.blocksUsed, fileEntry.eof);
@ -350,7 +349,7 @@ public class ProdosDisk
if (storageType < SUBDIRECTORY_HEADER
&& fileName.equals (new String (buffer, ptr + 1, nameLength)))
{
FileEntry fileEntry = new FileEntry (this, buffer, ptr);
FileEntry fileEntry = new FileEntry (this, ptr);
fileEntry.read ();
return Optional.of (fileEntry);
}
@ -393,7 +392,7 @@ public class ProdosDisk
updateFileCount (fileEntry.headerPointer);
SubdirectoryHeader subdirectoryHeader =
new SubdirectoryHeader (this, buffer, fileEntry.keyPointer * BLOCK_SIZE + 4);
new SubdirectoryHeader (this, fileEntry.keyPointer * BLOCK_SIZE + 4);
subdirectoryHeader.fileName = name;
subdirectoryHeader.creationDate = LocalDateTime.now ();
@ -424,16 +423,6 @@ public class ProdosDisk
}
}
// ---------------------------------------------------------------------------------//
// private int createExtendedKeyBlock (FileEntry fileEntry) throws DiskFullException
// // ---------------------------------------------------------------------------------//
// {
// int blockNo = allocateNextBlock ();
// ExtendedKeyBlock extendedKeyBlock = new ExtendedKeyBlock (blockNo);
//
// return blockNo;
// }
// ---------------------------------------------------------------------------------//
int allocateNextBlock () throws DiskFullException
// ---------------------------------------------------------------------------------//
@ -469,7 +458,7 @@ public class ProdosDisk
for (int i = 0; i < ENTRIES_PER_BLOCK; i++)
{
if (buffer[ptr] == 0) // free slot
return new FileEntry (this, buffer, ptr);
return new FileEntry (this, ptr);
ptr += ENTRY_SIZE;
}
@ -492,7 +481,7 @@ public class ProdosDisk
// update parent's file entry size (this is the subdirectory file entry
subdirectoryHeader.updateParentFileEntry ();
return new FileEntry (this, buffer, ptr + 4); // first slot in new block
return new FileEntry (this, ptr + 4); // first slot in new block
}
// ---------------------------------------------------------------------------------//

View File

@ -16,10 +16,10 @@ public class SubdirectoryHeader extends DirectoryHeader
private byte parentEntryLength;
// ---------------------------------------------------------------------------------//
public SubdirectoryHeader (ProdosDisk disk, byte[] buffer, int ptr)
public SubdirectoryHeader (ProdosDisk disk, int ptr)
// ---------------------------------------------------------------------------------//
{
super (disk, buffer, ptr);
super (disk, ptr);
storageType = (byte) 0x0E;
access = (byte) 0xC3;
@ -38,7 +38,7 @@ public class SubdirectoryHeader extends DirectoryHeader
FileEntry getParentFileEntry ()
// ---------------------------------------------------------------------------------//
{
FileEntry fileEntry = new FileEntry (disk, buffer,
FileEntry fileEntry = new FileEntry (disk,
parentPointer * BLOCK_SIZE + (parentEntry - 1) * ENTRY_SIZE + 4);
fileEntry.read ();

View File

@ -11,10 +11,10 @@ public class VolumeDirectoryHeader extends DirectoryHeader
int totalBlocks;
// ---------------------------------------------------------------------------------//
public VolumeDirectoryHeader (ProdosDisk disk, byte[] buffer, int ptr)
public VolumeDirectoryHeader (ProdosDisk disk, int ptr)
// ---------------------------------------------------------------------------------//
{
super (disk, buffer, ptr);
super (disk, ptr);
storageType = (byte) 0x0F;
}