mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-06-03 04:29:29 +00:00
Added changes per John Matthews fixes for AppleCommander 1.2.3.
See http://www.wright.edu/~john.matthews/ac.html.
This commit is contained in:
parent
9709fe8a03
commit
070c3d8b63
|
@ -254,6 +254,15 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry {
|
||||||
return AppleUtil.getWordValue(readFileEntry(), 0x25);
|
return AppleUtil.getWordValue(readFileEntry(), 0x25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the block number of the block for the directory which describes this file.
|
||||||
|
*/
|
||||||
|
public void setHeaderPointer(int headerPointer) {
|
||||||
|
byte[] entry = readFileEntry();
|
||||||
|
AppleUtil.setWordValue(entry, 0x25, headerPointer);
|
||||||
|
writeFileEntry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify if this file is locked.
|
* Identify if this file is locked.
|
||||||
*/
|
*/
|
||||||
|
@ -296,7 +305,19 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry {
|
||||||
*/
|
*/
|
||||||
public void delete() {
|
public void delete() {
|
||||||
getDisk().freeBlocks(this);
|
getDisk().freeBlocks(this);
|
||||||
setStorageType(0);
|
|
||||||
|
//decrement file count in header block
|
||||||
|
int headerBlock = getHeaderPointer();
|
||||||
|
byte[] data = getDisk().readBlock(headerBlock);
|
||||||
|
int fileCount = AppleUtil.getWordValue(data, 0x25);
|
||||||
|
if (fileCount != 0) fileCount--;
|
||||||
|
AppleUtil.setWordValue(data, 0x25, fileCount);
|
||||||
|
getDisk().writeBlock(headerBlock, data);
|
||||||
|
|
||||||
|
//clear storage type and name length
|
||||||
|
data = readFileEntry();
|
||||||
|
data[0] = 0;
|
||||||
|
writeFileEntry(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -127,6 +127,7 @@ filetype.f9=P16
|
||||||
filetype.fa=INT
|
filetype.fa=INT
|
||||||
filetype.fb=IVR
|
filetype.fb=IVR
|
||||||
filetype.fc=BAS
|
filetype.fc=BAS
|
||||||
|
filetype.fc.address=true
|
||||||
filetype.fd=VAR
|
filetype.fd=VAR
|
||||||
filetype.fe=REL
|
filetype.fe=REL
|
||||||
filetype.ff=SYS
|
filetype.ff=SYS
|
||||||
|
|
|
@ -189,6 +189,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
throws DiskFullException {
|
throws DiskFullException {
|
||||||
|
|
||||||
int blockNumber = directory.getFileEntryBlock();
|
int blockNumber = directory.getFileEntryBlock();
|
||||||
|
int headerBlock = blockNumber;
|
||||||
while (blockNumber != 0) {
|
while (blockNumber != 0) {
|
||||||
byte[] block = readBlock(blockNumber);
|
byte[] block = readBlock(blockNumber);
|
||||||
int offset = 4;
|
int offset = 4;
|
||||||
|
@ -197,6 +198,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
if ((value & 0xf0) == 0) {
|
if ((value & 0xf0) == 0) {
|
||||||
ProdosFileEntry fileEntry =
|
ProdosFileEntry fileEntry =
|
||||||
new ProdosFileEntry(this, blockNumber, offset);
|
new ProdosFileEntry(this, blockNumber, offset);
|
||||||
|
fileEntry.setKeyPointer(0); //may have been recycled
|
||||||
fileEntry.setCreationDate(new Date());
|
fileEntry.setCreationDate(new Date());
|
||||||
fileEntry.setProdosVersion(0);
|
fileEntry.setProdosVersion(0);
|
||||||
fileEntry.setMinimumProdosVersion(0);
|
fileEntry.setMinimumProdosVersion(0);
|
||||||
|
@ -204,7 +206,8 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
fileEntry.setCanRead(true);
|
fileEntry.setCanRead(true);
|
||||||
fileEntry.setCanRename(true);
|
fileEntry.setCanRename(true);
|
||||||
fileEntry.setCanWrite(true);
|
fileEntry.setCanWrite(true);
|
||||||
fileEntry.setSaplingFile();
|
fileEntry.setSeedlingFile();
|
||||||
|
fileEntry.setHeaderPointer(headerBlock);
|
||||||
fileEntry.setFilename("BLANK");
|
fileEntry.setFilename("BLANK");
|
||||||
directory.incrementFileCount();
|
directory.incrementFileCount();
|
||||||
return fileEntry;
|
return fileEntry;
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
*/
|
*/
|
||||||
package com.webcodepro.applecommander.storage;
|
package com.webcodepro.applecommander.storage;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the given file data for text.
|
* Filter the given file data for text.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -34,28 +37,31 @@ public class TextFileFilter implements FileFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the given FileEntry and return a byte array with filtered data.
|
* Process the given FileEntry and return a byte array
|
||||||
* @see com.webcodepro.applecommander.storage.FileFilter#filter(byte[])
|
* with filtered data; use PrintWriter to get platform
|
||||||
|
* agnostic line endings.
|
||||||
*/
|
*/
|
||||||
public byte[] filter(FileEntry fileEntry) {
|
public byte[] filter(FileEntry fileEntry) {
|
||||||
byte[] fileData = fileEntry.getFileData();
|
byte[] fileData = fileEntry.getFileData();
|
||||||
byte[] workingData = new byte[fileData.length];
|
int offset = 0;
|
||||||
int position = 0;
|
ByteArrayOutputStream byteArray = new
|
||||||
for (int i=0; i<fileData.length; i++) {
|
ByteArrayOutputStream(fileData.length);
|
||||||
byte byt = fileData[i];
|
PrintWriter printWriter = new PrintWriter(byteArray, true);
|
||||||
if (byt != 0) {
|
while (offset < fileData.length) {
|
||||||
if ((byt & 0x80) != 0) { // high bit set
|
char c = (char)(fileData[offset] & 0x7f);
|
||||||
workingData[position++] = (byte)(byt & 0x7f);
|
if (c != 0) {
|
||||||
|
if (c == 0x0d) { //Apple line end
|
||||||
|
printWriter.println();
|
||||||
} else {
|
} else {
|
||||||
workingData[position++] = byt;
|
printWriter.print(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
offset++;
|
||||||
}
|
}
|
||||||
byte[] filteredData = new byte[position];
|
return byteArray.toByteArray();
|
||||||
System.arraycopy(workingData, 0, filteredData, 0, filteredData.length);
|
|
||||||
return filteredData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give suggested file name.
|
* Give suggested file name.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -333,6 +333,11 @@ public class AppleUtil {
|
||||||
year = gc.get(GregorianCalendar.YEAR);
|
year = gc.get(GregorianCalendar.YEAR);
|
||||||
minute = gc.get(GregorianCalendar.MINUTE);
|
minute = gc.get(GregorianCalendar.MINUTE);
|
||||||
hour = gc.get(GregorianCalendar.HOUR_OF_DAY);
|
hour = gc.get(GregorianCalendar.HOUR_OF_DAY);
|
||||||
|
if (year >= 2000) {
|
||||||
|
year -= 2000;
|
||||||
|
} else {
|
||||||
|
year -= 1900;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int ymd = ((year & 0x7f) << 9) | ((month & 0xf) << 5) | (day & 0x1f);
|
int ymd = ((year & 0x7f) << 9) | ((month & 0xf) << 5) | (day & 0x1f);
|
||||||
int hm = ((hour & 0x1f) << 8) | (minute & 0x3f);
|
int hm = ((hour & 0x1f) << 8) | (minute & 0x3f);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user