mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: All refactor in DiscImageChef.Filesystems.
This commit is contained in:
@@ -40,9 +40,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
{
|
||||
public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
|
||||
{
|
||||
if(!mounted) return Errno.AccessDenied;
|
||||
|
||||
return Errno.NotImplemented;
|
||||
return !mounted ? Errno.AccessDenied : Errno.NotImplemented;
|
||||
}
|
||||
|
||||
public override Errno GetAttributes(string path, ref FileAttributes attributes)
|
||||
@@ -52,8 +50,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(pathElements.Length != 1) return Errno.NotSupported;
|
||||
|
||||
PascalFileEntry entry;
|
||||
Errno error = GetFileEntry(path, out entry);
|
||||
Errno error = GetFileEntry(path, out _);
|
||||
|
||||
if(error != Errno.NoError) return error;
|
||||
|
||||
@@ -71,16 +68,13 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
if(pathElements.Length != 1) return Errno.NotSupported;
|
||||
|
||||
byte[] file;
|
||||
Errno error;
|
||||
|
||||
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0))
|
||||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) file = catalogBlocks;
|
||||
else file = bootBlocks;
|
||||
file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ? catalogBlocks : bootBlocks;
|
||||
else
|
||||
{
|
||||
PascalFileEntry entry;
|
||||
error = GetFileEntry(path, out entry);
|
||||
Errno error = GetFileEntry(path, out PascalFileEntry entry);
|
||||
|
||||
if(error != Errno.NoError) return error;
|
||||
|
||||
@@ -113,16 +107,17 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0)
|
||||
{
|
||||
stat = new FileEntryInfo();
|
||||
stat.Attributes = new FileAttributes();
|
||||
stat.Attributes = FileAttributes.System;
|
||||
stat.BlockSize = device.GetSectorSize();
|
||||
stat.DeviceNo = 0;
|
||||
stat.GID = 0;
|
||||
stat.Inode = 0;
|
||||
stat.Links = 1;
|
||||
stat.Mode = 0x124;
|
||||
stat.UID = 0;
|
||||
stat = new FileEntryInfo
|
||||
{
|
||||
Attributes = FileAttributes.System,
|
||||
BlockSize = device.GetSectorSize(),
|
||||
DeviceNo = 0,
|
||||
GID = 0,
|
||||
Inode = 0,
|
||||
Links = 1,
|
||||
Mode = 0x124,
|
||||
UID = 0
|
||||
};
|
||||
|
||||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
|
||||
{
|
||||
@@ -138,24 +133,24 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
PascalFileEntry entry;
|
||||
Errno error = GetFileEntry(path, out entry);
|
||||
Errno error = GetFileEntry(path, out PascalFileEntry entry);
|
||||
|
||||
if(error != Errno.NoError) return error;
|
||||
|
||||
stat = new FileEntryInfo();
|
||||
stat.Attributes = new FileAttributes();
|
||||
stat.Attributes = FileAttributes.File;
|
||||
stat.Blocks = entry.lastBlock - entry.firstBlock;
|
||||
stat.BlockSize = device.GetSectorSize();
|
||||
stat.DeviceNo = 0;
|
||||
stat.GID = 0;
|
||||
stat.Inode = 0;
|
||||
stat.LastWriteTimeUtc = DateHandlers.UCSDPascalToDateTime(entry.mtime);
|
||||
stat.Length = (entry.lastBlock - entry.firstBlock) * device.GetSectorSize() + entry.lastBytes;
|
||||
stat.Links = 1;
|
||||
stat.Mode = 0x124;
|
||||
stat.UID = 0;
|
||||
stat = new FileEntryInfo
|
||||
{
|
||||
Attributes = FileAttributes.File,
|
||||
Blocks = entry.lastBlock - entry.firstBlock,
|
||||
BlockSize = device.GetSectorSize(),
|
||||
DeviceNo = 0,
|
||||
GID = 0,
|
||||
Inode = 0,
|
||||
LastWriteTimeUtc = DateHandlers.UCSDPascalToDateTime(entry.mtime),
|
||||
Length = (entry.lastBlock - entry.firstBlock) * device.GetSectorSize() + entry.lastBytes,
|
||||
Links = 1,
|
||||
Mode = 0x124,
|
||||
UID = 0
|
||||
};
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
@@ -143,14 +143,16 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
|
||||
information = sbInformation.ToString();
|
||||
|
||||
xmlFSType = new FileSystemType();
|
||||
xmlFSType.Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(imagePlugin.ReadSectors(partition.Start, 2));
|
||||
xmlFSType.Clusters = volEntry.blocks;
|
||||
xmlFSType.ClusterSize = (int)imagePlugin.GetSectorSize();
|
||||
xmlFSType.Files = volEntry.files;
|
||||
xmlFSType.FilesSpecified = true;
|
||||
xmlFSType.Type = "UCSD Pascal";
|
||||
xmlFSType.VolumeName = StringHandlers.PascalToString(volEntry.volumeName, CurrentEncoding);
|
||||
XmlFsType = new FileSystemType
|
||||
{
|
||||
Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(imagePlugin.ReadSectors(partition.Start, 2)),
|
||||
Clusters = volEntry.blocks,
|
||||
ClusterSize = (int)imagePlugin.GetSectorSize(),
|
||||
Files = volEntry.files,
|
||||
FilesSpecified = true,
|
||||
Type = "UCSD Pascal",
|
||||
VolumeName = StringHandlers.PascalToString(volEntry.volumeName, CurrentEncoding)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,14 +78,16 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
fileEntries = new List<PascalFileEntry>();
|
||||
while(offset + 26 < catalogBlocks.Length)
|
||||
{
|
||||
PascalFileEntry entry = new PascalFileEntry();
|
||||
entry.filename = new byte[16];
|
||||
entry.firstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x00);
|
||||
entry.lastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x02);
|
||||
entry.entryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x04);
|
||||
PascalFileEntry entry = new PascalFileEntry
|
||||
{
|
||||
filename = new byte[16],
|
||||
firstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x00),
|
||||
lastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x02),
|
||||
entryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x04),
|
||||
lastBytes = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x16),
|
||||
mtime = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x18)
|
||||
};
|
||||
Array.Copy(catalogBlocks, offset + 0x06, entry.filename, 0, 16);
|
||||
entry.lastBytes = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x16);
|
||||
entry.mtime = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x18);
|
||||
|
||||
if(entry.filename[0] <= 15 && entry.filename[0] > 0) fileEntries.Add(entry);
|
||||
|
||||
@@ -94,14 +96,16 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
|
||||
bootBlocks = device.ReadSectors(0, 2);
|
||||
|
||||
xmlFSType = new FileSystemType();
|
||||
xmlFSType.Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(bootBlocks);
|
||||
xmlFSType.Clusters = mountedVolEntry.blocks;
|
||||
xmlFSType.ClusterSize = (int)device.GetSectorSize();
|
||||
xmlFSType.Files = mountedVolEntry.files;
|
||||
xmlFSType.FilesSpecified = true;
|
||||
xmlFSType.Type = "UCSD Pascal";
|
||||
xmlFSType.VolumeName = StringHandlers.PascalToString(mountedVolEntry.volumeName, CurrentEncoding);
|
||||
XmlFsType = new FileSystemType
|
||||
{
|
||||
Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(bootBlocks),
|
||||
Clusters = mountedVolEntry.blocks,
|
||||
ClusterSize = (int)device.GetSectorSize(),
|
||||
Files = mountedVolEntry.files,
|
||||
FilesSpecified = true,
|
||||
Type = "UCSD Pascal",
|
||||
VolumeName = StringHandlers.PascalToString(mountedVolEntry.volumeName, CurrentEncoding)
|
||||
};
|
||||
|
||||
mounted = true;
|
||||
|
||||
@@ -122,7 +126,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
stat.FilenameLength = 16;
|
||||
stat.Files = (ulong)mountedVolEntry.files;
|
||||
stat.FreeBlocks = 0;
|
||||
stat.PluginId = PluginUUID;
|
||||
stat.PluginId = PluginUuid;
|
||||
stat.Type = "UCSD Pascal";
|
||||
|
||||
stat.FreeBlocks = mountedVolEntry.blocks - (mountedVolEntry.lastBlock - mountedVolEntry.firstBlock);
|
||||
|
||||
@@ -54,14 +54,14 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
public PascalPlugin()
|
||||
{
|
||||
Name = "U.C.S.D. Pascal filesystem";
|
||||
PluginUUID = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53");
|
||||
PluginUuid = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53");
|
||||
CurrentEncoding = new LisaRoman();
|
||||
}
|
||||
|
||||
public PascalPlugin(Encoding encoding)
|
||||
{
|
||||
Name = "U.C.S.D. Pascal filesystem";
|
||||
PluginUUID = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53");
|
||||
PluginUuid = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53");
|
||||
// TODO: Until Apple ][ encoding is implemented
|
||||
CurrentEncoding = new LisaRoman();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
{
|
||||
device = imagePlugin;
|
||||
Name = "U.C.S.D. Pascal filesystem";
|
||||
PluginUUID = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53");
|
||||
PluginUuid = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53");
|
||||
// TODO: Until Apple ][ encoding is implemented
|
||||
CurrentEncoding = new LisaRoman();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user