🎨REFACTOR: Use auto-properties.

This commit is contained in:
2017-12-26 08:01:40 +00:00
parent 94d8173b3a
commit 18f9a349c9
80 changed files with 947 additions and 1134 deletions

View File

@@ -92,7 +92,7 @@ namespace DiscImageChef.Filesystems.LisaFS
// as '-' is the path separator in Lisa OS
contents = (from entry in catalogCache
where entry.parentID == dirId
select StringHandlers.CToString(entry.filename, currentEncoding).Replace('/', '-')).ToList();
select StringHandlers.CToString(entry.filename, Encoding).Replace('/', '-')).ToList();
return Errno.NoError;
}
@@ -118,15 +118,17 @@ namespace DiscImageChef.Filesystems.LisaFS
// For each entry on the catalog
while(offset + 54 < buf.Length)
{
CatalogEntryV2 entV2 = new CatalogEntryV2();
entV2.filenameLen = buf[offset];
entV2.filename = new byte[E_NAME];
CatalogEntryV2 entV2 = new CatalogEntryV2
{
filenameLen = buf[offset],
filename = new byte[E_NAME],
unknown1 = buf[offset + 0x21],
fileType = buf[offset + 0x22],
unknown2 = buf[offset + 0x23],
fileID = BigEndianBitConverter.ToInt16(buf, offset + 0x24),
unknown3 = new byte[16]
};
Array.Copy(buf, offset + 0x01, entV2.filename, 0, E_NAME);
entV2.unknown1 = buf[offset + 0x21];
entV2.fileType = buf[offset + 0x22];
entV2.unknown2 = buf[offset + 0x23];
entV2.fileID = BigEndianBitConverter.ToInt16(buf, offset + 0x24);
entV2.unknown3 = new byte[16];
Array.Copy(buf, offset + 0x26, entV2.unknown3, 0, 16);
offset += 54;

View File

@@ -185,7 +185,7 @@ namespace DiscImageChef.Filesystems.LisaFS
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filenameLen = {1}", fileId, file.filenameLen);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filename = {1}", fileId,
StringHandlers.CToString(file.filename, currentEncoding));
StringHandlers.CToString(file.filename, Encoding));
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown1 = 0x{1:X4}", fileId, file.unknown1);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].file_uid = 0x{1:X16}", fileId, file.file_uid);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown2 = 0x{1:X2}", fileId, file.unknown2);
@@ -219,7 +219,7 @@ namespace DiscImageChef.Filesystems.LisaFS
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password_valid = {1}", fileId,
file.password_valid > 0);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password = {1}", fileId,
currentEncoding.GetString(file.password));
Encoding.GetString(file.password));
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown7 = 0x{1:X2}{2:X2}{3:X2}", fileId,
file.unknown7[0], file.unknown7[1], file.unknown7[2]);
DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].overhead = {1}", fileId, file.overhead);

View File

@@ -423,7 +423,7 @@ namespace DiscImageChef.Filesystems.LisaFS
foreach(CatalogEntry entry in catalogCache)
{
string filename = StringHandlers.CToString(entry.filename, currentEncoding);
string filename = StringHandlers.CToString(entry.filename, Encoding);
// LisaOS is case insensitive
if(string.Compare(wantedFilename, filename, StringComparison.InvariantCultureIgnoreCase) != 0 ||

View File

@@ -85,14 +85,12 @@ namespace DiscImageChef.Filesystems.LisaFS
DicConsole.DebugWriteLine("LisaFS plugin", "Current sector = {0}", i);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.mddf_block = {0}", infoMddf.mddf_block);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk size = {0} sectors",
imagePlugin.Info.Sectors);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk size = {0} sectors", imagePlugin.Info.Sectors);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size = {0} sectors", infoMddf.vol_size);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - 1 = {0}", infoMddf.volsize_minus_one);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - mddf.mddf_block -1 = {0}",
infoMddf.volsize_minus_mddf_minus_one);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk sector = {0} bytes",
imagePlugin.Info.SectorSize);
DicConsole.DebugWriteLine("LisaFS plugin", "Disk sector = {0} bytes", imagePlugin.Info.SectorSize);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.blocksize = {0} bytes", infoMddf.blocksize);
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.datasize = {0} bytes", infoMddf.datasize);
@@ -120,9 +118,10 @@ namespace DiscImageChef.Filesystems.LisaFS
}
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
Encoding encoding)
{
currentEncoding = new LisaRoman();
Encoding = new LisaRoman();
information = "";
StringBuilder sb = new StringBuilder();
@@ -161,11 +160,11 @@ namespace DiscImageChef.Filesystems.LisaFS
infoMddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
infoMddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
infoMddf.volname = StringHandlers.PascalToString(pString, currentEncoding);
infoMddf.volname = StringHandlers.PascalToString(pString, Encoding);
infoMddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
infoMddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, currentEncoding) : "";
infoMddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, Encoding) : "";
infoMddf.unknown2 = sector[0x4F];
infoMddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
infoMddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
@@ -351,27 +350,27 @@ namespace DiscImageChef.Filesystems.LisaFS
information = sb.ToString();
xmlFsType = new FileSystemType();
XmlFsType = new FileSystemType();
if(DateTime.Compare(infoMddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFsType.BackupDate = infoMddf.dtvb;
xmlFsType.BackupDateSpecified = true;
XmlFsType.BackupDate = infoMddf.dtvb;
XmlFsType.BackupDateSpecified = true;
}
xmlFsType.Clusters = infoMddf.vol_size;
xmlFsType.ClusterSize = infoMddf.clustersize * infoMddf.datasize;
XmlFsType.Clusters = infoMddf.vol_size;
XmlFsType.ClusterSize = infoMddf.clustersize * infoMddf.datasize;
if(DateTime.Compare(infoMddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFsType.CreationDate = infoMddf.dtvc;
xmlFsType.CreationDateSpecified = true;
XmlFsType.CreationDate = infoMddf.dtvc;
XmlFsType.CreationDateSpecified = true;
}
xmlFsType.Dirty = infoMddf.vol_left_mounted != 0;
xmlFsType.Files = infoMddf.filecount;
xmlFsType.FilesSpecified = true;
xmlFsType.FreeClusters = infoMddf.freecount;
xmlFsType.FreeClustersSpecified = true;
xmlFsType.Type = "LisaFS";
xmlFsType.VolumeName = infoMddf.volname;
xmlFsType.VolumeSerial = $"{infoMddf.volid:X16}";
XmlFsType.Dirty = infoMddf.vol_left_mounted != 0;
XmlFsType.Files = infoMddf.filecount;
XmlFsType.FilesSpecified = true;
XmlFsType.FreeClusters = infoMddf.freecount;
XmlFsType.FreeClustersSpecified = true;
XmlFsType.Type = "LisaFS";
XmlFsType.VolumeName = infoMddf.volname;
XmlFsType.VolumeSerial = $"{infoMddf.volid:X16}";
return;
}

View File

@@ -32,11 +32,9 @@
using System;
using System.Collections.Generic;
using Claunia.Encoding;
using DiscImageChef.CommonTypes;
using System.Text;
using DiscImageChef.DiscImages;
using Schemas;
using Encoding = System.Text.Encoding;
namespace DiscImageChef.Filesystems.LisaFS
{
@@ -44,9 +42,8 @@ namespace DiscImageChef.Filesystems.LisaFS
// Variable names from Lisa API
public partial class LisaFS : IReadOnlyFilesystem
{
IMediaImage device;
Encoding currentEncoding;
bool debug;
IMediaImage device;
int devTagSize;
MDDF mddf;
@@ -56,9 +53,8 @@ namespace DiscImageChef.Filesystems.LisaFS
public string Name => "Apple Lisa File System";
public Guid Id => new Guid("7E6034D1-D823-4248-A54D-239742B28391");
public Encoding Encoding => currentEncoding;
FileSystemType xmlFsType;
public FileSystemType XmlFsType => xmlFsType;
public Encoding Encoding { get; private set; }
public FileSystemType XmlFsType { get; private set; }
#region Caches
/// <summary>Caches Extents Files</summary>

View File

@@ -52,7 +52,7 @@ namespace DiscImageChef.Filesystems.LisaFS
try
{
device = imagePlugin;
currentEncoding = new LisaRoman();
Encoding = new LisaRoman();
// Lisa OS is unable to work on disks without tags.
// This code is designed like that.
@@ -100,11 +100,11 @@ namespace DiscImageChef.Filesystems.LisaFS
mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
Array.Copy(sector, 0x0C, pString, 0, 33);
mddf.volname = StringHandlers.PascalToString(pString, currentEncoding);
mddf.volname = StringHandlers.PascalToString(pString, Encoding);
mddf.unknown1 = sector[0x2D];
Array.Copy(sector, 0x2E, pString, 0, 33);
// Prevent garbage
mddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, currentEncoding) : "";
mddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, Encoding) : "";
mddf.unknown2 = sector[0x4F];
mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
@@ -281,27 +281,27 @@ namespace DiscImageChef.Filesystems.LisaFS
}
// Create XML metadata for mounted filesystem
xmlFsType = new FileSystemType();
XmlFsType = new FileSystemType();
if(DateTime.Compare(mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFsType.BackupDate = mddf.dtvb;
xmlFsType.BackupDateSpecified = true;
XmlFsType.BackupDate = mddf.dtvb;
XmlFsType.BackupDateSpecified = true;
}
xmlFsType.Clusters = mddf.vol_size;
xmlFsType.ClusterSize = mddf.clustersize * mddf.datasize;
XmlFsType.Clusters = mddf.vol_size;
XmlFsType.ClusterSize = mddf.clustersize * mddf.datasize;
if(DateTime.Compare(mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
{
xmlFsType.CreationDate = mddf.dtvc;
xmlFsType.CreationDateSpecified = true;
XmlFsType.CreationDate = mddf.dtvc;
XmlFsType.CreationDateSpecified = true;
}
xmlFsType.Dirty = mddf.vol_left_mounted != 0;
xmlFsType.Files = mddf.filecount;
xmlFsType.FilesSpecified = true;
xmlFsType.FreeClusters = mddf.freecount;
xmlFsType.FreeClustersSpecified = true;
xmlFsType.Type = "LisaFS";
xmlFsType.VolumeName = mddf.volname;
xmlFsType.VolumeSerial = $"{mddf.volid:X16}";
XmlFsType.Dirty = mddf.vol_left_mounted != 0;
XmlFsType.Files = mddf.filecount;
XmlFsType.FilesSpecified = true;
XmlFsType.FreeClusters = mddf.freecount;
XmlFsType.FreeClustersSpecified = true;
XmlFsType.Type = "LisaFS";
XmlFsType.VolumeName = mddf.volname;
XmlFsType.VolumeSerial = $"{mddf.volid:X16}";
return Errno.NoError;
}