mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Reformat code.
This commit is contained in:
@@ -64,8 +64,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
public uint magic;
|
||||
public uint version;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] homeFilesystem;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] homeFilesystem;
|
||||
public ushort entries;
|
||||
}
|
||||
|
||||
@@ -126,12 +125,18 @@ namespace DiscImageChef.Filters
|
||||
const uint AppleSingleVersion = 0x00010000;
|
||||
const uint AppleSingleVersion2 = 0x00020000;
|
||||
|
||||
readonly byte[] MacintoshHome = { 0x4D, 0x61, 0x63, 0x69, 0x6E, 0x74, 0x6F, 0x73, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
|
||||
readonly byte[] ProDOSHome = { 0x50, 0x72, 0x6F, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
|
||||
readonly byte[] DOSHome = { 0x4D, 0x53, 0x2D, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
|
||||
readonly byte[] UNIXHome = { 0x55, 0x6E, 0x69, 0x78, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
|
||||
readonly byte[] VMSHome = { 0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
|
||||
readonly byte[] OSXHome = { 0x4D, 0x61, 0x63, 0x20, 0x4F, 0x53, 0x20, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
|
||||
readonly byte[] MacintoshHome =
|
||||
{0x4D, 0x61, 0x63, 0x69, 0x6E, 0x74, 0x6F, 0x73, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
readonly byte[] ProDOSHome =
|
||||
{0x50, 0x72, 0x6F, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
readonly byte[] DOSHome =
|
||||
{0x4D, 0x53, 0x2D, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
readonly byte[] UNIXHome =
|
||||
{0x55, 0x6E, 0x69, 0x78, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
readonly byte[] VMSHome =
|
||||
{0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
readonly byte[] OSXHome =
|
||||
{0x4D, 0x61, 0x63, 0x20, 0x4F, 0x53, 0x20, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
|
||||
AppleSingleEntry dataFork;
|
||||
AppleSingleEntry rsrcFork;
|
||||
@@ -152,8 +157,7 @@ namespace DiscImageChef.Filters
|
||||
public override void Close()
|
||||
{
|
||||
bytes = null;
|
||||
if(stream != null)
|
||||
stream.Close();
|
||||
if(stream != null) stream.Close();
|
||||
isBytes = false;
|
||||
isStream = false;
|
||||
isPath = false;
|
||||
@@ -177,15 +181,13 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override Stream GetDataForkStream()
|
||||
{
|
||||
if(dataFork.length == 0)
|
||||
return null;
|
||||
if(dataFork.length == 0) return null;
|
||||
|
||||
if(isBytes)
|
||||
return new OffsetStream(bytes, dataFork.offset, dataFork.offset + dataFork.length - 1);
|
||||
if(isStream)
|
||||
return new OffsetStream(stream, dataFork.offset, dataFork.offset + dataFork.length - 1);
|
||||
if(isBytes) return new OffsetStream(bytes, dataFork.offset, dataFork.offset + dataFork.length - 1);
|
||||
if(isStream) return new OffsetStream(stream, dataFork.offset, dataFork.offset + dataFork.length - 1);
|
||||
if(isPath)
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, dataFork.offset, dataFork.offset + dataFork.length - 1);
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, dataFork.offset,
|
||||
dataFork.offset + dataFork.length - 1);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -222,15 +224,13 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override Stream GetResourceForkStream()
|
||||
{
|
||||
if(rsrcFork.length == 0)
|
||||
return null;
|
||||
if(rsrcFork.length == 0) return null;
|
||||
|
||||
if(isBytes)
|
||||
return new OffsetStream(bytes, rsrcFork.offset, rsrcFork.offset + rsrcFork.length - 1);
|
||||
if(isStream)
|
||||
return new OffsetStream(stream, rsrcFork.offset, rsrcFork.offset + rsrcFork.length - 1);
|
||||
if(isBytes) return new OffsetStream(bytes, rsrcFork.offset, rsrcFork.offset + rsrcFork.length - 1);
|
||||
if(isStream) return new OffsetStream(stream, rsrcFork.offset, rsrcFork.offset + rsrcFork.length - 1);
|
||||
if(isPath)
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, rsrcFork.offset, rsrcFork.offset + rsrcFork.length - 1);
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, rsrcFork.offset,
|
||||
rsrcFork.offset + rsrcFork.length - 1);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -242,41 +242,41 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override bool Identify(byte[] buffer)
|
||||
{
|
||||
if(buffer == null || buffer.Length < 26)
|
||||
return false;
|
||||
if(buffer == null || buffer.Length < 26) return false;
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
Array.Copy(buffer, 0, hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
return header.magic == AppleSingleMagic && (header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
return header.magic == AppleSingleMagic &&
|
||||
(header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
}
|
||||
|
||||
public override bool Identify(Stream stream)
|
||||
{
|
||||
if(stream == null || stream.Length < 26)
|
||||
return false;
|
||||
if(stream == null || stream.Length < 26) return false;
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
stream.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
return header.magic == AppleSingleMagic && (header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
return header.magic == AppleSingleMagic &&
|
||||
(header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
}
|
||||
|
||||
public override bool Identify(string path)
|
||||
{
|
||||
FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
if(fstream == null || fstream.Length < 26)
|
||||
return false;
|
||||
if(fstream == null || fstream.Length < 26) return false;
|
||||
|
||||
byte[] hdr_b = new byte[26];
|
||||
fstream.Read(hdr_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleHeader>(hdr_b);
|
||||
|
||||
fstream.Close();
|
||||
return header.magic == AppleSingleMagic && (header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
return header.magic == AppleSingleMagic &&
|
||||
(header.version == AppleSingleVersion || header.version == AppleSingleVersion2);
|
||||
}
|
||||
|
||||
public override bool IsOpened()
|
||||
@@ -314,7 +314,8 @@ namespace DiscImageChef.Filters
|
||||
ms.Seek(entry.offset, SeekOrigin.Begin);
|
||||
byte[] dates_b = new byte[16];
|
||||
ms.Read(dates_b, 0, 16);
|
||||
AppleSingleFileDates dates = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
AppleSingleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.AppleDoubleToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.AppleDoubleToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -324,26 +325,31 @@ namespace DiscImageChef.Filters
|
||||
ms.Read(finfo, 0, finfo.Length);
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleMacFileInfo macinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
AppleSingleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleProDOSFileInfo prodosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
AppleSingleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleUNIXFileInfo unixinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
AppleSingleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleDOSFileInfo dosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime = DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
AppleSingleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
break;
|
||||
case AppleSingleEntryID.ResourceFork:
|
||||
@@ -387,7 +393,8 @@ namespace DiscImageChef.Filters
|
||||
stream.Seek(entry.offset, SeekOrigin.Begin);
|
||||
byte[] dates_b = new byte[16];
|
||||
stream.Read(dates_b, 0, 16);
|
||||
AppleSingleFileDates dates = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
AppleSingleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.MacToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -397,26 +404,31 @@ namespace DiscImageChef.Filters
|
||||
stream.Read(finfo, 0, finfo.Length);
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleMacFileInfo macinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
AppleSingleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleProDOSFileInfo prodosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
AppleSingleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleUNIXFileInfo unixinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
AppleSingleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleDOSFileInfo dosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime = DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
AppleSingleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
break;
|
||||
case AppleSingleEntryID.ResourceFork:
|
||||
@@ -461,7 +473,8 @@ namespace DiscImageChef.Filters
|
||||
fs.Seek(entry.offset, SeekOrigin.Begin);
|
||||
byte[] dates_b = new byte[16];
|
||||
fs.Read(dates_b, 0, 16);
|
||||
AppleSingleFileDates dates = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
AppleSingleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.MacToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -471,26 +484,31 @@ namespace DiscImageChef.Filters
|
||||
fs.Read(finfo, 0, finfo.Length);
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleMacFileInfo macinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
AppleSingleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleProDOSFileInfo prodosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
AppleSingleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleUNIXFileInfo unixinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
AppleSingleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleSingleDOSFileInfo dosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime = DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
AppleSingleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleSingleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
break;
|
||||
case AppleSingleEntryID.ResourceFork:
|
||||
@@ -505,5 +523,4 @@ namespace DiscImageChef.Filters
|
||||
basePath = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user