mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-18 05:30:29 +00:00
tidying
This commit is contained in:
parent
7d79f8f365
commit
73e964fe76
@ -10,7 +10,6 @@ public class FileWriter
|
|||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final ProdosDisk disk;
|
private final ProdosDisk disk;
|
||||||
private final byte[] buffer;
|
|
||||||
|
|
||||||
private IndexBlock indexBlock = null;
|
private IndexBlock indexBlock = null;
|
||||||
private MasterIndexBlock masterIndexBlock = null;
|
private MasterIndexBlock masterIndexBlock = null;
|
||||||
@ -25,7 +24,6 @@ public class FileWriter
|
|||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.disk = disk;
|
this.disk = disk;
|
||||||
this.buffer = disk.getBuffer ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
@ -45,7 +43,7 @@ public class FileWriter
|
|||||||
int bufferPtr = actualBlockNo * BLOCK_SIZE;
|
int bufferPtr = actualBlockNo * BLOCK_SIZE;
|
||||||
int tfr = Math.min (remaining, BLOCK_SIZE);
|
int tfr = Math.min (remaining, BLOCK_SIZE);
|
||||||
|
|
||||||
System.arraycopy (dataBuffer, dataPtr, buffer, bufferPtr, tfr);
|
System.arraycopy (dataBuffer, dataPtr, disk.getBuffer (), bufferPtr, tfr);
|
||||||
|
|
||||||
dataPtr += BLOCK_SIZE;
|
dataPtr += BLOCK_SIZE;
|
||||||
remaining -= BLOCK_SIZE;
|
remaining -= BLOCK_SIZE;
|
||||||
@ -78,7 +76,7 @@ public class FileWriter
|
|||||||
int actualBlockNo = getActualBlockNo (logicalBlockNo);
|
int actualBlockNo = getActualBlockNo (logicalBlockNo);
|
||||||
int bufferPtr = actualBlockNo * BLOCK_SIZE + blockOffset;
|
int bufferPtr = actualBlockNo * BLOCK_SIZE + blockOffset;
|
||||||
|
|
||||||
System.arraycopy (dataBuffer, dataPtr, buffer, bufferPtr, tfr);
|
System.arraycopy (dataBuffer, dataPtr, disk.getBuffer (), bufferPtr, tfr);
|
||||||
|
|
||||||
destPtr += tfr;
|
destPtr += tfr;
|
||||||
dataPtr += tfr;
|
dataPtr += tfr;
|
||||||
@ -134,9 +132,9 @@ public class FileWriter
|
|||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (storageType == TREE)
|
if (storageType == TREE)
|
||||||
masterIndexBlock.write (buffer);
|
masterIndexBlock.write (disk.getBuffer ());
|
||||||
else if (storageType == SAPLING)
|
else if (storageType == SAPLING)
|
||||||
indexBlock.write (buffer);
|
indexBlock.write (disk.getBuffer ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
@ -156,7 +154,7 @@ public class FileWriter
|
|||||||
else if (storageType == SEEDLING) // seedling -> sapling -> tree
|
else if (storageType == SEEDLING) // seedling -> sapling -> tree
|
||||||
{
|
{
|
||||||
indexBlock = new IndexBlock (allocateNextBlock ());
|
indexBlock = new IndexBlock (allocateNextBlock ());
|
||||||
indexBlock.set (0, keyPointer);
|
indexBlock.setPosition (0, keyPointer);
|
||||||
masterIndexBlock.set (0, indexBlock);
|
masterIndexBlock.set (0, indexBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,38 +163,39 @@ public class FileWriter
|
|||||||
indexBlock = null;
|
indexBlock = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexBlock (logicalBlockNo / 256).set (logicalBlockNo % 256, actualBlockNo);
|
getIndexBlock (logicalBlockNo / 0x100).setPosition (logicalBlockNo % 0x100,
|
||||||
|
actualBlockNo);
|
||||||
}
|
}
|
||||||
else if (logicalBlockNo > 0) // potential SAPLING
|
else if (logicalBlockNo > 0) // potential SAPLING
|
||||||
{
|
{
|
||||||
if (storageType == TREE) // already a tree
|
if (storageType == TREE) // already a tree
|
||||||
{
|
{
|
||||||
getIndexBlock (0).set (logicalBlockNo, actualBlockNo);
|
getIndexBlock (0).setPosition (logicalBlockNo, actualBlockNo);
|
||||||
}
|
}
|
||||||
else if (storageType == SAPLING) // already a sapling
|
else if (storageType == SAPLING) // already a sapling
|
||||||
{
|
{
|
||||||
indexBlock.set (logicalBlockNo, actualBlockNo);
|
indexBlock.setPosition (logicalBlockNo, actualBlockNo);
|
||||||
}
|
}
|
||||||
else // new file or already a seedling
|
else // new file or already a seedling
|
||||||
{
|
{
|
||||||
indexBlock = new IndexBlock (allocateNextBlock ());
|
indexBlock = new IndexBlock (allocateNextBlock ());
|
||||||
if (storageType == SEEDLING) // seedling -> sapling
|
if (storageType == SEEDLING) // seedling -> sapling
|
||||||
indexBlock.set (0, keyPointer);
|
indexBlock.setPosition (0, keyPointer);
|
||||||
|
|
||||||
keyPointer = indexBlock.blockNo;
|
keyPointer = indexBlock.blockNo;
|
||||||
storageType = SAPLING;
|
storageType = SAPLING;
|
||||||
indexBlock.set (logicalBlockNo, actualBlockNo);
|
indexBlock.setPosition (logicalBlockNo, actualBlockNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (logicalBlockNo == 0) // potential SEEDLING
|
else if (logicalBlockNo == 0) // potential SEEDLING
|
||||||
{
|
{
|
||||||
if (storageType == TREE) // already a tree
|
if (storageType == TREE) // already a tree
|
||||||
{
|
{
|
||||||
getIndexBlock (0).set (0, actualBlockNo);
|
getIndexBlock (0).setPosition (0, actualBlockNo);
|
||||||
}
|
}
|
||||||
else if (storageType == SAPLING) // already a sapling
|
else if (storageType == SAPLING) // already a sapling
|
||||||
{
|
{
|
||||||
indexBlock.set (0, actualBlockNo);
|
indexBlock.setPosition (0, actualBlockNo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ public class IndexBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
void set (int position, int actualBlockNo)
|
void setPosition (int position, int actualBlockNo)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (blocks[position] == 0)
|
if (blocks[position] == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user