🐛Correct UCSD Pascal filesystem on Apple II disks.

This commit is contained in:
2018-01-06 00:41:14 +00:00
parent 4b359e71f8
commit 38725e5625
6 changed files with 167 additions and 134 deletions

View File

@@ -70,17 +70,22 @@ namespace DiscImageChef.Filesystems.UCSDPascal
byte[] file;
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0))
file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ? catalogBlocks : bootBlocks;
file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0
? catalogBlocks
: bootBlocks;
else
{
Errno error = GetFileEntry(path, out PascalFileEntry entry);
if(error != Errno.NoError) return error;
byte[] tmp = device.ReadSectors((ulong)entry.firstBlock, (uint)(entry.lastBlock - entry.firstBlock));
file = new byte[(entry.lastBlock - entry.firstBlock - 1) * device.Info.SectorSize + entry.lastBytes];
byte[] tmp = device.ReadSectors((ulong)entry.FirstBlock * multiplier,
(uint)(entry.LastBlock - entry.FirstBlock) * multiplier);
file = new byte[(entry.LastBlock - entry.FirstBlock - 1) *
device.Info.SectorSize * multiplier +
entry.LastBytes];
Array.Copy(tmp, 0, file, 0, file.Length);
}
@@ -103,19 +108,19 @@ namespace DiscImageChef.Filesystems.UCSDPascal
if(pathElements.Length != 1) return Errno.NotSupported;
if(debug)
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0)
{
stat = new FileEntryInfo
{
Attributes = FileAttributes.System,
BlockSize = device.Info.SectorSize,
DeviceNo = 0,
GID = 0,
Inode = 0,
Links = 1,
Mode = 0x124,
UID = 0
BlockSize = device.Info.SectorSize * multiplier,
DeviceNo = 0,
GID = 0,
Inode = 0,
Links = 1,
Mode = 0x124,
UID = 0
};
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
@@ -138,17 +143,18 @@ namespace DiscImageChef.Filesystems.UCSDPascal
stat = new FileEntryInfo
{
Attributes = FileAttributes.File,
Blocks = entry.lastBlock - entry.firstBlock,
BlockSize = device.Info.SectorSize,
DeviceNo = 0,
GID = 0,
Inode = 0,
LastWriteTimeUtc = DateHandlers.UcsdPascalToDateTime(entry.mtime),
Length = (entry.lastBlock - entry.firstBlock) * device.Info.SectorSize + entry.lastBytes,
Attributes = FileAttributes.File,
Blocks = entry.LastBlock - entry.FirstBlock,
BlockSize = device.Info.SectorSize * multiplier,
DeviceNo = 0,
GID = 0,
Inode = 0,
LastWriteTimeUtc = DateHandlers.UcsdPascalToDateTime(entry.ModificationTime),
Length = (entry.LastBlock - entry.FirstBlock) * device.Info.SectorSize * multiplier +
entry.LastBytes,
Links = 1,
Mode = 0x124,
UID = 0
Mode = 0x124,
UID = 0
};
return Errno.NoError;
@@ -161,10 +167,10 @@ namespace DiscImageChef.Filesystems.UCSDPascal
foreach(PascalFileEntry ent in fileEntries.Where(ent =>
string.Compare(path,
StringHandlers
.PascalToString(ent.filename,
Encoding),
.PascalToString(ent.Filename,
Encoding),
StringComparison
.InvariantCultureIgnoreCase) == 0))
.InvariantCultureIgnoreCase) == 0))
{
entry = ent;
return Errno.NoError;