fixed some constants

This commit is contained in:
Denis Molony 2021-04-19 14:01:27 +10:00
parent 59290f7d25
commit 20121431af

View File

@ -1,5 +1,9 @@
package com.bytezone.diskbrowser.prodos.write; package com.bytezone.diskbrowser.prodos.write;
import static com.bytezone.diskbrowser.prodos.ProdosConstants.ENTRIES_PER_BLOCK;
import static com.bytezone.diskbrowser.prodos.ProdosConstants.FILE_TYPE_DIRECTORY;
import static com.bytezone.diskbrowser.prodos.ProdosConstants.SUBDIRECTORY;
import static com.bytezone.diskbrowser.prodos.ProdosConstants.SUBDIRECTORY_HEADER;
import static com.bytezone.diskbrowser.utilities.Utility.readShort; import static com.bytezone.diskbrowser.utilities.Utility.readShort;
import static com.bytezone.diskbrowser.utilities.Utility.writeShort; import static com.bytezone.diskbrowser.utilities.Utility.writeShort;
@ -196,7 +200,7 @@ public class ProdosDisk
{ {
int offset = blockNo * BLOCK_SIZE; int offset = blockNo * BLOCK_SIZE;
int ptr = offset + 4; int ptr = offset + 4;
for (int i = 0; i < 13; i++) for (int i = 0; i < ENTRIES_PER_BLOCK; i++)
{ {
int storageTypeNameLength = buffer[ptr] & 0xFF; int storageTypeNameLength = buffer[ptr] & 0xFF;
if (storageTypeNameLength == 0) if (storageTypeNameLength == 0)
@ -209,7 +213,7 @@ public class ProdosDisk
int nameLength = buffer[ptr] & 0x0F; int nameLength = buffer[ptr] & 0x0F;
int storageType = (buffer[ptr] & 0xF0) >>> 4; int storageType = (buffer[ptr] & 0xF0) >>> 4;
if (storageType < 0x0E if (storageType < SUBDIRECTORY_HEADER
&& fileName.equals (new String (buffer, ptr + 1, nameLength))) && fileName.equals (new String (buffer, ptr + 1, nameLength)))
{ {
FileEntry fileEntry = new FileEntry (this, buffer, ptr); FileEntry fileEntry = new FileEntry (this, buffer, ptr);
@ -234,12 +238,12 @@ public class ProdosDisk
if (fileEntry != null) if (fileEntry != null)
{ {
fileEntry.storageType = 0x0D; // subdirectory fileEntry.storageType = SUBDIRECTORY;
fileEntry.fileName = name; fileEntry.fileName = name;
fileEntry.keyPointer = allocateNextBlock (); fileEntry.keyPointer = allocateNextBlock ();
fileEntry.blocksUsed = 1; fileEntry.blocksUsed = 1;
fileEntry.eof = 512; fileEntry.eof = BLOCK_SIZE;
fileEntry.fileType = 0x0F; // DIR fileEntry.fileType = FILE_TYPE_DIRECTORY;
fileEntry.headerPointer = blockNo; fileEntry.headerPointer = blockNo;
fileEntry.creationDate = LocalDateTime.now (); fileEntry.creationDate = LocalDateTime.now ();
fileEntry.modifiedDate = LocalDateTime.now (); fileEntry.modifiedDate = LocalDateTime.now ();
@ -318,7 +322,7 @@ public class ProdosDisk
int offset = blockNo * BLOCK_SIZE; int offset = blockNo * BLOCK_SIZE;
int ptr = offset + 4; int ptr = offset + 4;
for (int i = 0; i < 13; i++) for (int i = 0; i < ENTRIES_PER_BLOCK; i++)
{ {
if (buffer[ptr] == 0) // free slot if (buffer[ptr] == 0) // free slot
return new FileEntry (this, buffer, ptr); return new FileEntry (this, buffer, ptr);