mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Code cleanup.
This commit is contained in:
@@ -44,21 +44,21 @@ namespace DiscImageChef.Filters
|
||||
/// </summary>
|
||||
public class PCExchange : IFilter
|
||||
{
|
||||
const string FILE_ID = "FILEID.DAT";
|
||||
const string FILE_ID = "FILEID.DAT";
|
||||
const string FINDER_INFO = "FINDER.DAT";
|
||||
const string RESOURCES = "RESOURCE.FRK";
|
||||
string basePath;
|
||||
DateTime creationTime;
|
||||
long dataLen;
|
||||
string dataPath;
|
||||
DateTime lastWriteTime;
|
||||
const string RESOURCES = "RESOURCE.FRK";
|
||||
string basePath;
|
||||
DateTime creationTime;
|
||||
long dataLen;
|
||||
string dataPath;
|
||||
DateTime lastWriteTime;
|
||||
|
||||
bool opened;
|
||||
long rsrcLen;
|
||||
bool opened;
|
||||
long rsrcLen;
|
||||
string rsrcPath;
|
||||
|
||||
public string Name => "PCExchange";
|
||||
public Guid Id => new Guid("9264EB9F-D634-4F9B-BE12-C24CD44988C6");
|
||||
public Guid Id => new Guid("9264EB9F-D634-4F9B-BE12-C24CD44988C6");
|
||||
|
||||
public void Close()
|
||||
{
|
||||
@@ -155,16 +155,17 @@ namespace DiscImageChef.Filters
|
||||
|
||||
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
||||
{
|
||||
PCExchangeEntry datEntry = new PCExchangeEntry();
|
||||
byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)];
|
||||
PCExchangeEntry datEntry = new PCExchangeEntry();
|
||||
byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)];
|
||||
finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry));
|
||||
datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian<PCExchangeEntry>(datEntry_b);
|
||||
// TODO: Add support for encoding on filters
|
||||
string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
|
||||
string macName =
|
||||
StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
|
||||
byte[] tmpDosName_b = new byte[8];
|
||||
byte[] tmpDosExt_b = new byte[3];
|
||||
byte[] tmpDosExt_b = new byte[3];
|
||||
Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8);
|
||||
Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
|
||||
Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
|
||||
string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." +
|
||||
Encoding.ASCII.GetString(tmpDosExt_b).Trim();
|
||||
string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture);
|
||||
@@ -173,7 +174,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
dataFound |=
|
||||
File.Exists(Path.Combine(parentFolder, macName ?? throw new InvalidOperationException())) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosName)) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosName)) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosNameLow));
|
||||
|
||||
rsrcFound |= File.Exists(Path.Combine(parentFolder, RESOURCES, dosName)) ||
|
||||
@@ -213,15 +214,16 @@ namespace DiscImageChef.Filters
|
||||
|
||||
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
||||
{
|
||||
PCExchangeEntry datEntry = new PCExchangeEntry();
|
||||
byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)];
|
||||
PCExchangeEntry datEntry = new PCExchangeEntry();
|
||||
byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)];
|
||||
finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry));
|
||||
datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian<PCExchangeEntry>(datEntry_b);
|
||||
string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
|
||||
string macName =
|
||||
StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
|
||||
byte[] tmpDosName_b = new byte[8];
|
||||
byte[] tmpDosExt_b = new byte[3];
|
||||
byte[] tmpDosExt_b = new byte[3];
|
||||
Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8);
|
||||
Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
|
||||
Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
|
||||
string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." +
|
||||
Encoding.ASCII.GetString(tmpDosExt_b).Trim();
|
||||
string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture);
|
||||
@@ -233,17 +235,17 @@ namespace DiscImageChef.Filters
|
||||
else if(File.Exists(Path.Combine(parentFolder, dosName)))
|
||||
dataPath = Path.Combine(parentFolder, dosName);
|
||||
else if(File.Exists(Path.Combine(parentFolder, dosNameLow)))
|
||||
dataPath = Path.Combine(parentFolder, dosNameLow);
|
||||
dataPath = Path.Combine(parentFolder, dosNameLow);
|
||||
else dataPath = null;
|
||||
|
||||
if(File.Exists(Path.Combine(parentFolder, RESOURCES, dosName)))
|
||||
rsrcPath = Path.Combine(parentFolder, RESOURCES, dosName);
|
||||
else if(File.Exists(Path.Combine(parentFolder, RESOURCES, dosNameLow)))
|
||||
rsrcPath = Path.Combine(parentFolder, RESOURCES, dosNameLow);
|
||||
rsrcPath = Path.Combine(parentFolder, RESOURCES, dosNameLow);
|
||||
else rsrcPath = null;
|
||||
|
||||
lastWriteTime = DateHandlers.MacToDateTime(datEntry.modificationDate);
|
||||
creationTime = DateHandlers.MacToDateTime(datEntry.creationDate);
|
||||
creationTime = DateHandlers.MacToDateTime(datEntry.creationDate);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -252,7 +254,7 @@ namespace DiscImageChef.Filters
|
||||
rsrcLen = new FileInfo(rsrcPath ?? throw new InvalidOperationException()).Length;
|
||||
|
||||
basePath = path;
|
||||
opened = true;
|
||||
opened = true;
|
||||
|
||||
finderDatStream.Close();
|
||||
}
|
||||
@@ -264,7 +266,8 @@ namespace DiscImageChef.Filters
|
||||
/// Name in Macintosh. If PCExchange version supports FAT's LFN they are the same.
|
||||
/// Illegal characters for FAT get substituted with '_' both here and in FAT's LFN entry.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] macName;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
||||
public byte[] macName;
|
||||
/// <summary>
|
||||
/// File type
|
||||
/// </summary>
|
||||
@@ -288,7 +291,8 @@ namespace DiscImageChef.Filters
|
||||
/// <summary>
|
||||
/// Unknown, all bytes are empty but last, except in volume's label entry
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)] public byte[] unknown1;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)]
|
||||
public byte[] unknown1;
|
||||
/// <summary>
|
||||
/// File's creation date
|
||||
/// </summary>
|
||||
@@ -310,7 +314,8 @@ namespace DiscImageChef.Filters
|
||||
/// Name as in FAT entry (not LFN).
|
||||
/// Resource fork file is always using this name, never LFN.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] public byte[] dosName;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
|
||||
public byte[] dosName;
|
||||
/// <summary>
|
||||
/// Unknown, flags?
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user