Read support for GS/OS filename upper/lower-case support.

This commit is contained in:
Rob Greene 2022-06-21 20:07:10 -05:00
parent e7c10faf3b
commit a4d9c5e746
1 changed files with 19 additions and 0 deletions

View File

@ -106,6 +106,25 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry {
}
fileName = mixedCase.toString();
}
// GS/OS upper/lower case mix
if ((getMinimumProdosVersion() & 0x80) != 0) {
int flags = getMinimumProdosVersion() << 8 | getProdosVersion();
int bit = 1 << 14; // 1st bit in 16 bit number is enablement flag, so skipping it
StringBuffer mixedCase = new StringBuffer(fileName);
for (int i=0; i<16 && i<fileName.length(); i++) {
boolean lowerCase = (flags & bit) != 0;
if (lowerCase) {
char ch = mixedCase.charAt(i);
if (ch == '.') {
mixedCase.setCharAt(i, ' ');
} else {
mixedCase.setCharAt(i, Character.toLowerCase(ch));
}
}
bit >>= 1;
}
fileName = mixedCase.toString();
}
return fileName;
}