mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-27 03:29:26 +00:00
bug when adding a catalog block to the top level
This commit is contained in:
parent
d0bfde2e80
commit
e135b65948
@ -120,6 +120,7 @@ public class ProdosDisk
|
|||||||
LocalDateTime modified, byte[] dataBuffer) throws DiskFullException
|
LocalDateTime modified, byte[] dataBuffer) throws DiskFullException
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// split the full path into an array of subdirectories and a file name
|
||||||
String[] subdirectories;
|
String[] subdirectories;
|
||||||
String fileName = "";
|
String fileName = "";
|
||||||
|
|
||||||
@ -135,6 +136,7 @@ public class ProdosDisk
|
|||||||
fileName = path;
|
fileName = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search for each subdirectory, create any that don't exist
|
||||||
int catalogBlockNo = 2;
|
int catalogBlockNo = 2;
|
||||||
|
|
||||||
for (int i = 0; i < subdirectories.length; i++)
|
for (int i = 0; i < subdirectories.length; i++)
|
||||||
@ -146,6 +148,7 @@ public class ProdosDisk
|
|||||||
catalogBlockNo = fileEntry.keyPointer;
|
catalogBlockNo = fileEntry.keyPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check that the file doesn't already exist
|
||||||
FileEntry fileEntry = searchDirectory (catalogBlockNo, fileName);
|
FileEntry fileEntry = searchDirectory (catalogBlockNo, fileName);
|
||||||
if (fileEntry != null)
|
if (fileEntry != null)
|
||||||
{
|
{
|
||||||
@ -154,6 +157,7 @@ public class ProdosDisk
|
|||||||
return null; // throw something?
|
return null; // throw something?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create the file in the current catalog block
|
||||||
fileEntry = findFreeSlot (catalogBlockNo);
|
fileEntry = findFreeSlot (catalogBlockNo);
|
||||||
|
|
||||||
if (fileEntry != null)
|
if (fileEntry != null)
|
||||||
@ -312,8 +316,10 @@ public class ProdosDisk
|
|||||||
private FileEntry findFreeSlot (int blockNo) throws DiskFullException
|
private FileEntry findFreeSlot (int blockNo) throws DiskFullException
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
// get the subdirectory header before the blockNo possibly changes
|
||||||
SubdirectoryHeader subdirectoryHeader = subdirectoryHeaders.get (blockNo);
|
SubdirectoryHeader subdirectoryHeader = subdirectoryHeaders.get (blockNo);
|
||||||
int lastBlockNo = 0;
|
|
||||||
|
int lastBlockNo = 0; // used for linking directory blocks
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -335,7 +341,9 @@ public class ProdosDisk
|
|||||||
// no free slots, so add a new catalog block
|
// no free slots, so add a new catalog block
|
||||||
blockNo = allocateNextBlock ();
|
blockNo = allocateNextBlock ();
|
||||||
|
|
||||||
// update file entry size
|
// update file entry size (if not the Volume Directory)
|
||||||
|
if (subdirectoryHeader != null)
|
||||||
|
{
|
||||||
FileEntry fileEntry =
|
FileEntry fileEntry =
|
||||||
new FileEntry (this, buffer, subdirectoryHeader.parentPointer * BLOCK_SIZE
|
new FileEntry (this, buffer, subdirectoryHeader.parentPointer * BLOCK_SIZE
|
||||||
+ (subdirectoryHeader.parentEntry - 1) * ENTRY_SIZE + 4);
|
+ (subdirectoryHeader.parentEntry - 1) * ENTRY_SIZE + 4);
|
||||||
@ -344,6 +352,7 @@ public class ProdosDisk
|
|||||||
fileEntry.eof += BLOCK_SIZE;
|
fileEntry.eof += BLOCK_SIZE;
|
||||||
fileEntry.modifiedDate = LocalDateTime.now ();
|
fileEntry.modifiedDate = LocalDateTime.now ();
|
||||||
fileEntry.write ();
|
fileEntry.write ();
|
||||||
|
}
|
||||||
|
|
||||||
// update links
|
// update links
|
||||||
int ptr = blockNo * BLOCK_SIZE;
|
int ptr = blockNo * BLOCK_SIZE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user