Compare commits

..

No commits in common. "bc0993e9d3d247888cefb41466e73171fe656aab" and "09c4542118366e47d76fe990abc519fe5e216801" have entirely different histories.

2 changed files with 20 additions and 17 deletions

View File

@ -30,7 +30,6 @@ public class BasicTextFile extends TextFile
super (name, buffer);
this.eof = eof;
recordLength = auxType;
prodosFile = true;
}

View File

@ -4,8 +4,6 @@ package com.bytezone.diskbrowser.applefile;
public class PascalText extends TextFile
// -----------------------------------------------------------------------------------//
{
private final static int PAGE_SIZE = 1024;
// ---------------------------------------------------------------------------------//
public PascalText (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
@ -18,34 +16,28 @@ public class PascalText extends TextFile
public String getText ()
// ---------------------------------------------------------------------------------//
{
// Text files are broken up into 1024-byte pages.
// [DLE] [indent] [text] [CR] ... [nulls]
StringBuilder text = new StringBuilder (getHeader ());
int ptr = PAGE_SIZE; // skip text editor header
int ptr = 0x400;
while (ptr < buffer.length)
{
if (buffer[ptr] == 0x00) // padding to page boundary
if (buffer[ptr] == 0x00)
{
ptr = (ptr / PAGE_SIZE + 1) * PAGE_SIZE; // skip to next page
++ptr;
continue;
}
if (buffer[ptr] == 0x10) // Data Link Escape code
if (buffer[ptr] == 0x10)
{
int tab = (buffer[ptr + 1] & 0xFF) - 32; // indent amaount
int tab = buffer[ptr + 1] - 0x20;
while (tab-- > 0)
text.append (" ");
ptr += 2;
}
while (buffer[ptr] != 0x0D)
text.append ((char) buffer[ptr++]);
text.append ("\n");
ptr++;
String line = getLine (ptr);
text.append (line + "\n");
ptr += line.length () + 1;
}
if (text.length () > 0)
@ -53,4 +45,16 @@ public class PascalText extends TextFile
return text.toString ();
}
// ---------------------------------------------------------------------------------//
private String getLine (int ptr)
// ---------------------------------------------------------------------------------//
{
StringBuilder line = new StringBuilder ();
while (buffer[ptr] != 0x0D)
line.append ((char) buffer[ptr++]);
return line.toString ();
}
}