nulleric
/Fix-a-Fork
/amendments
/27
Handle files smaller than the buffer.
eric made amendment 27 about 1 year ago
--- main.c Sat Nov 11 16:38:45 2023
+++ main.c Sat Nov 11 16:53:23 2023
@@ -106,7 +106,8 @@ OSErr openFile(unsigned char *fName, short fRefNum, sh
short i = 0, j = 0;
err = FSRead(fRefNum, &count, gBuf);
- if(err) return err;
+ // eofErr == partial read, probably small file, ok to continue.
+ if(err && err != eofErr) return err;
// Check for magic in first 1024 bytes
if(isBinHex4())
found = true;
@@ -126,7 +127,7 @@ OSErr openFile(unsigned char *fName, short fRefNum, sh
found = true;
// Checks @ 1024
- if(!found)
+ if(!found && count >= 2048)
{
SetFPos(fRefNum, fsFromStart, 1024);
FSRead(fRefNum, &count, gBuf);