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 AppleDoubleVersion = 0x00010000;
|
||||
const uint AppleDoubleVersion2 = 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[] VMXHome = { 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[] VMXHome =
|
||||
{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};
|
||||
|
||||
AppleDoubleEntry dataFork;
|
||||
AppleDoubleEntry rsrcFork;
|
||||
@@ -205,10 +210,10 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override Stream GetResourceForkStream()
|
||||
{
|
||||
if(rsrcFork.length == 0)
|
||||
return null;
|
||||
if(rsrcFork.length == 0) return null;
|
||||
|
||||
return new OffsetStream(headerPath, FileMode.Open, FileAccess.Read, rsrcFork.offset, rsrcFork.offset + rsrcFork.length - 1);
|
||||
return new OffsetStream(headerPath, FileMode.Open, FileAccess.Read, rsrcFork.offset,
|
||||
rsrcFork.offset + rsrcFork.length - 1);
|
||||
}
|
||||
|
||||
public override bool HasResourceFork()
|
||||
@@ -270,8 +275,8 @@ namespace DiscImageChef.Filters
|
||||
prodosStream.Read(prodos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(prodos_b);
|
||||
prodosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,8 +290,8 @@ namespace DiscImageChef.Filters
|
||||
unixStream.Read(unix_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unix_b);
|
||||
unixStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,8 +305,8 @@ namespace DiscImageChef.Filters
|
||||
dosStream.Read(dos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dos_b);
|
||||
dosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,8 +320,8 @@ namespace DiscImageChef.Filters
|
||||
doslStream.Read(dosl_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dosl_b);
|
||||
doslStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,8 +335,8 @@ namespace DiscImageChef.Filters
|
||||
netatalkStream.Read(netatalk_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(netatalk_b);
|
||||
netatalkStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,8 +350,8 @@ namespace DiscImageChef.Filters
|
||||
daveStream.Read(dave_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dave_b);
|
||||
daveStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,8 +365,8 @@ namespace DiscImageChef.Filters
|
||||
osxStream.Read(osx_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(osx_b);
|
||||
osxStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,8 +380,8 @@ namespace DiscImageChef.Filters
|
||||
unarStream.Read(unar_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
||||
unarStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
return true;
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +447,8 @@ namespace DiscImageChef.Filters
|
||||
prodosStream.Read(prodos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(prodos_b);
|
||||
prodosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = ProDosAppleDouble;
|
||||
}
|
||||
}
|
||||
@@ -457,7 +463,8 @@ namespace DiscImageChef.Filters
|
||||
unixStream.Read(unix_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unix_b);
|
||||
unixStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = UNIXAppleDouble;
|
||||
}
|
||||
}
|
||||
@@ -472,7 +479,8 @@ namespace DiscImageChef.Filters
|
||||
dosStream.Read(dos_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dos_b);
|
||||
dosStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = DOSAppleDouble;
|
||||
}
|
||||
}
|
||||
@@ -487,7 +495,8 @@ namespace DiscImageChef.Filters
|
||||
doslStream.Read(dosl_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dosl_b);
|
||||
doslStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = DOSAppleDoubleLower;
|
||||
}
|
||||
}
|
||||
@@ -502,7 +511,8 @@ namespace DiscImageChef.Filters
|
||||
netatalkStream.Read(netatalk_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(netatalk_b);
|
||||
netatalkStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = NetatalkAppleDouble;
|
||||
}
|
||||
}
|
||||
@@ -517,7 +527,8 @@ namespace DiscImageChef.Filters
|
||||
daveStream.Read(dave_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(dave_b);
|
||||
daveStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = DAVEAppleDouble;
|
||||
}
|
||||
}
|
||||
@@ -532,7 +543,8 @@ namespace DiscImageChef.Filters
|
||||
osxStream.Read(osx_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(osx_b);
|
||||
osxStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = OSXAppleDouble;
|
||||
}
|
||||
}
|
||||
@@ -547,7 +559,8 @@ namespace DiscImageChef.Filters
|
||||
unarStream.Read(unar_b, 0, 26);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
||||
unarStream.Close();
|
||||
if(header.magic == AppleDoubleMagic && (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
if(header.magic == AppleDoubleMagic &&
|
||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2))
|
||||
headerPath = UnArAppleDouble;
|
||||
}
|
||||
}
|
||||
@@ -580,7 +593,8 @@ namespace DiscImageChef.Filters
|
||||
fs.Seek(entry.offset, SeekOrigin.Begin);
|
||||
byte[] dates_b = new byte[16];
|
||||
fs.Read(dates_b, 0, 16);
|
||||
AppleDoubleFileDates dates = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleFileDates>(dates_b);
|
||||
AppleDoubleFileDates dates =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleFileDates>(dates_b);
|
||||
creationTime = DateHandlers.AppleDoubleToDateTime(dates.creationDate);
|
||||
lastWriteTime = DateHandlers.AppleDoubleToDateTime(dates.modificationDate);
|
||||
break;
|
||||
@@ -590,26 +604,31 @@ namespace DiscImageChef.Filters
|
||||
fs.Read(finfo, 0, finfo.Length);
|
||||
if(MacintoshHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleMacFileInfo macinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleMacFileInfo>(finfo);
|
||||
AppleDoubleMacFileInfo macinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleMacFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
|
||||
}
|
||||
else if(ProDOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleProDOSFileInfo prodosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleProDOSFileInfo>(finfo);
|
||||
AppleDoubleProDOSFileInfo prodosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleProDOSFileInfo>(finfo);
|
||||
creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
|
||||
}
|
||||
else if(UNIXHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleUNIXFileInfo unixinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleUNIXFileInfo>(finfo);
|
||||
AppleDoubleUNIXFileInfo unixinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleUNIXFileInfo>(finfo);
|
||||
creationTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.creationDate);
|
||||
lastWriteTime = DateHandlers.UNIXUnsignedToDateTime(unixinfo.modificationDate);
|
||||
}
|
||||
else if(DOSHome.SequenceEqual(header.homeFilesystem))
|
||||
{
|
||||
AppleDoubleDOSFileInfo dosinfo = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleDOSFileInfo>(finfo);
|
||||
lastWriteTime = DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
AppleDoubleDOSFileInfo dosinfo =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleDOSFileInfo>(finfo);
|
||||
lastWriteTime =
|
||||
DateHandlers.DOSToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
|
||||
}
|
||||
break;
|
||||
case AppleDoubleEntryID.ResourceFork:
|
||||
@@ -632,4 +651,4 @@ namespace DiscImageChef.Filters
|
||||
basePath = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,8 +55,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if(dataStream != null)
|
||||
dataStream.Close();
|
||||
if(dataStream != null) dataStream.Close();
|
||||
dataStream = null;
|
||||
basePath = null;
|
||||
opened = false;
|
||||
@@ -94,11 +93,13 @@ namespace DiscImageChef.Filters
|
||||
if(buffer.Length > 512)
|
||||
{
|
||||
// Check it is not an UDIF
|
||||
if(buffer[buffer.Length - 512] == 0x6B && buffer[buffer.Length - 511] == 0x6F && buffer[buffer.Length - 510] == 0x6C && buffer[buffer.Length - 509] == 0x79)
|
||||
return false;
|
||||
if(buffer[buffer.Length - 512] == 0x6B && buffer[buffer.Length - 511] == 0x6F &&
|
||||
buffer[buffer.Length - 510] == 0x6C && buffer[buffer.Length - 509] == 0x79) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,11 +119,12 @@ namespace DiscImageChef.Filters
|
||||
stream.Read(buffer, 0, 4);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
// Check it is not an UDIF
|
||||
if(buffer[0] == 0x6B && buffer[1] == 0x6F && buffer[2] == 0x6C && buffer[3] == 0x79)
|
||||
return false;
|
||||
if(buffer[0] == 0x6B && buffer[1] == 0x6F && buffer[2] == 0x6C && buffer[3] == 0x79) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -137,7 +139,8 @@ namespace DiscImageChef.Filters
|
||||
stream.Read(buffer, 0, 4);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
if(buffer[0] == 0x42 && buffer[1] == 0x5A && buffer[2] == 0x68 && buffer[3] >= 0x31 && buffer[3] <= 0x39)
|
||||
if(buffer[0] == 0x42 && buffer[1] == 0x5A && buffer[2] == 0x68 && buffer[3] >= 0x31 && buffer[3] <= 0x39
|
||||
)
|
||||
{
|
||||
if(stream.Length > 512)
|
||||
{
|
||||
@@ -148,6 +151,7 @@ namespace DiscImageChef.Filters
|
||||
if(buffer[0] == 0x6B && buffer[1] == 0x6F && buffer[2] == 0x6C && buffer[3] == 0x79)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -220,12 +224,12 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override string GetFilename()
|
||||
{
|
||||
if(basePath == null)
|
||||
return null;
|
||||
if(basePath == null) return null;
|
||||
if(basePath.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 4);
|
||||
if(basePath.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 6);
|
||||
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,7 @@ namespace DiscImageChef.Filters
|
||||
public string Name;
|
||||
public Guid UUID;
|
||||
|
||||
protected Filter()
|
||||
{
|
||||
}
|
||||
protected Filter() { }
|
||||
|
||||
/// <summary>
|
||||
/// Closes all opened streams.
|
||||
@@ -169,5 +167,4 @@ namespace DiscImageChef.Filters
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
public abstract void Open(byte[] buffer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,10 +59,7 @@ namespace DiscImageChef.Filters
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Exception {0}", exception);
|
||||
}
|
||||
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,23 +73,21 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
if(filter.Identify(path))
|
||||
{
|
||||
Filter foundFilter = (Filter)filter.GetType().GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
|
||||
Filter foundFilter =
|
||||
(Filter)filter.GetType().GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
|
||||
foundFilter.Open(path);
|
||||
|
||||
if(foundFilter.IsOpened())
|
||||
return foundFilter;
|
||||
if(foundFilter.IsOpened()) return foundFilter;
|
||||
}
|
||||
}
|
||||
else
|
||||
noFilter = filter;
|
||||
else noFilter = filter;
|
||||
}
|
||||
|
||||
if(noFilter.Identify(path))
|
||||
{
|
||||
noFilter.Open(path);
|
||||
|
||||
if(noFilter.IsOpened())
|
||||
return noFilter;
|
||||
if(noFilter.IsOpened()) return noFilter;
|
||||
}
|
||||
|
||||
return noFilter;
|
||||
@@ -103,5 +98,4 @@ namespace DiscImageChef.Filters
|
||||
return filtersList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,8 +60,7 @@ namespace DiscImageChef.Filters
|
||||
baseStream = (T)Activator.CreateInstance(typeof(T), parameters);
|
||||
backFile = Path.GetTempFileName();
|
||||
backStream = new FileStream(backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||
if(length == 0)
|
||||
CalculateLength();
|
||||
if(length == 0) CalculateLength();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,53 +99,34 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseStream.CanRead;
|
||||
}
|
||||
get { return baseStream.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return streamLength;
|
||||
}
|
||||
get { return streamLength; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return backStream.Position;
|
||||
}
|
||||
get { return backStream.Position; }
|
||||
|
||||
set
|
||||
{
|
||||
SetPosition(value);
|
||||
}
|
||||
set { SetPosition(value); }
|
||||
}
|
||||
|
||||
void SetPosition(long position)
|
||||
{
|
||||
if(position == backStream.Position)
|
||||
return;
|
||||
if(position == backStream.Position) return;
|
||||
|
||||
if(position < backStream.Length)
|
||||
{
|
||||
@@ -205,15 +185,14 @@ namespace DiscImageChef.Filters
|
||||
switch(origin)
|
||||
{
|
||||
case SeekOrigin.Begin:
|
||||
if(offset < 0)
|
||||
throw new IOException("Cannot seek before stream start.");
|
||||
if(offset < 0) throw new IOException("Cannot seek before stream start.");
|
||||
|
||||
SetPosition(offset);
|
||||
break;
|
||||
case SeekOrigin.End:
|
||||
if(offset > 0)
|
||||
throw new IOException("Cannot seek after stream end.");
|
||||
if(streamLength == 0)
|
||||
CalculateLength();
|
||||
if(offset > 0) throw new IOException("Cannot seek after stream end.");
|
||||
|
||||
if(streamLength == 0) CalculateLength();
|
||||
SetPosition(streamLength + offset);
|
||||
break;
|
||||
default:
|
||||
@@ -236,17 +215,14 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if(backStream!=null)
|
||||
backStream.Close();
|
||||
if(backStream != null) backStream.Close();
|
||||
File.Delete(backFile);
|
||||
}
|
||||
|
||||
~ForcedSeekStream()
|
||||
{
|
||||
if(backStream != null)
|
||||
backStream.Close();
|
||||
if(backStream != null) backStream.Close();
|
||||
File.Delete(backFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,8 +54,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if(dataStream != null)
|
||||
dataStream.Close();
|
||||
if(dataStream != null) dataStream.Close();
|
||||
dataStream = null;
|
||||
basePath = null;
|
||||
opened = false;
|
||||
@@ -225,12 +224,12 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override string GetFilename()
|
||||
{
|
||||
if(basePath == null)
|
||||
return null;
|
||||
if(basePath == null) return null;
|
||||
if(basePath.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 3);
|
||||
if(basePath.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 5);
|
||||
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if(dataStream != null)
|
||||
dataStream.Close();
|
||||
if(dataStream != null) dataStream.Close();
|
||||
dataStream = null;
|
||||
basePath = null;
|
||||
opened = false;
|
||||
@@ -89,7 +88,8 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override bool Identify(byte[] buffer)
|
||||
{
|
||||
return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 && buffer[4] == 0x01;
|
||||
return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 &&
|
||||
buffer[4] == 0x01;
|
||||
}
|
||||
|
||||
public override bool Identify(Stream stream)
|
||||
@@ -100,7 +100,8 @@ namespace DiscImageChef.Filters
|
||||
stream.Read(buffer, 0, 5);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 && buffer[4] == 0x01;
|
||||
return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 &&
|
||||
buffer[4] == 0x01;
|
||||
}
|
||||
|
||||
public override bool Identify(string path)
|
||||
@@ -114,7 +115,8 @@ namespace DiscImageChef.Filters
|
||||
stream.Read(buffer, 0, 5);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 && buffer[4] == 0x01;
|
||||
return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 &&
|
||||
buffer[4] == 0x01;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -127,7 +129,8 @@ namespace DiscImageChef.Filters
|
||||
creationTime = DateTime.UtcNow;
|
||||
lastWriteTime = creationTime;
|
||||
decompressedSize = BitConverter.ToInt64(buffer, buffer.Length - 16);
|
||||
innerStream = new ForcedSeekStream<LZipStream>(decompressedSize, dataStream, CompressionMode.Decompress, false);
|
||||
innerStream =
|
||||
new ForcedSeekStream<LZipStream>(decompressedSize, dataStream, CompressionMode.Decompress, false);
|
||||
opened = true;
|
||||
}
|
||||
|
||||
@@ -138,11 +141,12 @@ namespace DiscImageChef.Filters
|
||||
creationTime = DateTime.UtcNow;
|
||||
lastWriteTime = creationTime;
|
||||
byte[] tmp = new byte[8];
|
||||
dataStream.Seek(-16 ,SeekOrigin.End);
|
||||
dataStream.Seek(-16, SeekOrigin.End);
|
||||
dataStream.Read(tmp, 0, 8);
|
||||
decompressedSize = BitConverter.ToInt64(tmp, 0);
|
||||
dataStream.Seek(0, SeekOrigin.Begin);
|
||||
innerStream = new ForcedSeekStream<LZipStream>(decompressedSize, dataStream, CompressionMode.Decompress, false);
|
||||
innerStream =
|
||||
new ForcedSeekStream<LZipStream>(decompressedSize, dataStream, CompressionMode.Decompress, false);
|
||||
opened = true;
|
||||
}
|
||||
|
||||
@@ -162,7 +166,8 @@ namespace DiscImageChef.Filters
|
||||
dataStream.Read(tmp, 0, 8);
|
||||
decompressedSize = BitConverter.ToInt64(tmp, 0);
|
||||
dataStream.Seek(0, SeekOrigin.Begin);
|
||||
innerStream = new ForcedSeekStream<LZipStream>(decompressedSize, dataStream, CompressionMode.Decompress, false);
|
||||
innerStream =
|
||||
new ForcedSeekStream<LZipStream>(decompressedSize, dataStream, CompressionMode.Decompress, false);
|
||||
opened = true;
|
||||
}
|
||||
|
||||
@@ -193,12 +198,12 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override string GetFilename()
|
||||
{
|
||||
if(basePath == null)
|
||||
return null;
|
||||
if(basePath == null) return null;
|
||||
if(basePath.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 3);
|
||||
if(basePath.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 5);
|
||||
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Filters
|
||||
/// <summary>
|
||||
/// 0x01, Str63 Pascal filename
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||
public byte[] filename;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public byte[] filename;
|
||||
/// <summary>
|
||||
/// 0x41, File type
|
||||
/// </summary>
|
||||
@@ -112,6 +111,7 @@ namespace DiscImageChef.Filters
|
||||
/// 0x65, Low byte of Finder flags
|
||||
/// </summary>
|
||||
public byte finderFlags2;
|
||||
|
||||
#region MacBinary III
|
||||
/// <summary>
|
||||
/// 0x66, magic identifier, "mBIN"
|
||||
@@ -126,6 +126,7 @@ namespace DiscImageChef.Filters
|
||||
/// </summary>
|
||||
public byte fdXFlags;
|
||||
#endregion MacBinary III
|
||||
|
||||
/// <summary>
|
||||
/// 0x6C, unused
|
||||
/// </summary>
|
||||
@@ -134,6 +135,7 @@ namespace DiscImageChef.Filters
|
||||
/// 0x74, Total unpacked files
|
||||
/// </summary>
|
||||
public uint totalPackedFiles;
|
||||
|
||||
#region MacBinary II
|
||||
/// <summary>
|
||||
/// 0x78, Length of secondary header
|
||||
@@ -152,6 +154,7 @@ namespace DiscImageChef.Filters
|
||||
/// </summary>
|
||||
public short crc;
|
||||
#endregion MacBinary II
|
||||
|
||||
/// <summary>
|
||||
/// 0x7E, Reserved for computer type and OS ID
|
||||
/// </summary>
|
||||
@@ -180,8 +183,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;
|
||||
@@ -205,15 +207,13 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override Stream GetDataForkStream()
|
||||
{
|
||||
if(header.dataLength == 0)
|
||||
return null;
|
||||
if(header.dataLength == 0) return null;
|
||||
|
||||
if(isBytes)
|
||||
return new OffsetStream(bytes, dataForkOff, dataForkOff + header.dataLength - 1);
|
||||
if(isStream)
|
||||
return new OffsetStream(stream, dataForkOff, dataForkOff + header.dataLength - 1);
|
||||
if(isBytes) return new OffsetStream(bytes, dataForkOff, dataForkOff + header.dataLength - 1);
|
||||
if(isStream) return new OffsetStream(stream, dataForkOff, dataForkOff + header.dataLength - 1);
|
||||
if(isPath)
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, dataForkOff, dataForkOff + header.dataLength - 1);
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, dataForkOff,
|
||||
dataForkOff + header.dataLength - 1);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -250,15 +250,13 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override Stream GetResourceForkStream()
|
||||
{
|
||||
if(header.resourceLength == 0)
|
||||
return null;
|
||||
if(header.resourceLength == 0) return null;
|
||||
|
||||
if(isBytes)
|
||||
return new OffsetStream(bytes, rsrcForkOff, rsrcForkOff + header.resourceLength - 1);
|
||||
if(isStream)
|
||||
return new OffsetStream(stream, rsrcForkOff, rsrcForkOff + header.resourceLength - 1);
|
||||
if(isBytes) return new OffsetStream(bytes, rsrcForkOff, rsrcForkOff + header.resourceLength - 1);
|
||||
if(isStream) return new OffsetStream(stream, rsrcForkOff, rsrcForkOff + header.resourceLength - 1);
|
||||
if(isPath)
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, rsrcForkOff, rsrcForkOff + header.resourceLength - 1);
|
||||
return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, rsrcForkOff,
|
||||
rsrcForkOff + header.resourceLength - 1);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -270,47 +268,47 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override bool Identify(byte[] buffer)
|
||||
{
|
||||
if(buffer == null || buffer.Length < 128)
|
||||
return false;
|
||||
if(buffer == null || buffer.Length < 128) return false;
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
Array.Copy(buffer, 0, hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && header.filename[0] < 64 &&
|
||||
header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 && (
|
||||
header.dataLength > 0 || header.resourceLength > 0));
|
||||
return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 &&
|
||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||
header.zero2 == 0 && header.reserved == 0 &&
|
||||
(header.dataLength > 0 || header.resourceLength > 0));
|
||||
}
|
||||
|
||||
public override bool Identify(Stream stream)
|
||||
{
|
||||
if(stream == null || stream.Length < 128)
|
||||
return false;
|
||||
if(stream == null || stream.Length < 128) return false;
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
stream.Read(hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && header.filename[0] < 64 &&
|
||||
header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 && (
|
||||
header.dataLength > 0 || header.resourceLength > 0));
|
||||
return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 &&
|
||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||
header.zero2 == 0 && header.reserved == 0 &&
|
||||
(header.dataLength > 0 || header.resourceLength > 0));
|
||||
}
|
||||
|
||||
public override bool Identify(string path)
|
||||
{
|
||||
FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
if(fstream == null || fstream.Length < 128)
|
||||
return false;
|
||||
if(fstream == null || fstream.Length < 128) return false;
|
||||
|
||||
byte[] hdr_b = new byte[128];
|
||||
fstream.Read(hdr_b, 0, 128);
|
||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||
|
||||
fstream.Close();
|
||||
return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 && header.filename[0] < 64 &&
|
||||
header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 && (
|
||||
header.dataLength > 0 || header.resourceLength > 0));
|
||||
return header.magic == MacBinaryMagic || (header.version == 0 && header.filename[0] > 0 &&
|
||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||
header.zero2 == 0 && header.reserved == 0 &&
|
||||
(header.dataLength > 0 || header.resourceLength > 0));
|
||||
}
|
||||
|
||||
public override bool IsOpened()
|
||||
@@ -329,12 +327,10 @@ namespace DiscImageChef.Filters
|
||||
|
||||
uint blocks = 1;
|
||||
blocks += (uint)(header.secondaryHeaderLength / 128);
|
||||
if(header.secondaryHeaderLength % 128 > 0)
|
||||
blocks++;
|
||||
if(header.secondaryHeaderLength % 128 > 0) blocks++;
|
||||
dataForkOff = blocks * 128;
|
||||
blocks += header.dataLength / 128;
|
||||
if(header.dataLength % 128 > 0)
|
||||
blocks++;
|
||||
if(header.dataLength % 128 > 0) blocks++;
|
||||
rsrcForkOff = blocks * 128;
|
||||
|
||||
filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh"));
|
||||
@@ -357,12 +353,10 @@ namespace DiscImageChef.Filters
|
||||
|
||||
uint blocks = 1;
|
||||
blocks += (uint)(header.secondaryHeaderLength / 128);
|
||||
if(header.secondaryHeaderLength % 128 > 0)
|
||||
blocks++;
|
||||
if(header.secondaryHeaderLength % 128 > 0) blocks++;
|
||||
dataForkOff = blocks * 128;
|
||||
blocks += header.dataLength / 128;
|
||||
if(header.dataLength % 128 > 0)
|
||||
blocks++;
|
||||
if(header.dataLength % 128 > 0) blocks++;
|
||||
rsrcForkOff = blocks * 128;
|
||||
|
||||
filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh"));
|
||||
@@ -386,12 +380,10 @@ namespace DiscImageChef.Filters
|
||||
|
||||
uint blocks = 1;
|
||||
blocks += (uint)(header.secondaryHeaderLength / 128);
|
||||
if(header.secondaryHeaderLength % 128 > 0)
|
||||
blocks++;
|
||||
if(header.secondaryHeaderLength % 128 > 0) blocks++;
|
||||
dataForkOff = blocks * 128;
|
||||
blocks += header.dataLength / 128;
|
||||
if(header.dataLength % 128 > 0)
|
||||
blocks++;
|
||||
if(header.dataLength % 128 > 0) blocks++;
|
||||
rsrcForkOff = blocks * 128;
|
||||
|
||||
filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh"));
|
||||
@@ -404,4 +396,4 @@ namespace DiscImageChef.Filters
|
||||
basePath = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,291 +48,247 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public OffsetStream(Stream stream, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = stream;
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long start, long end)
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
|
||||
FileOptions options, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode, access, share, bufferSize, options);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(SafeFileHandle handle, FileAccess access, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(handle, access);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(SafeFileHandle handle, FileAccess access, int bufferSize, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(handle, access, bufferSize);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync, long start, long end)
|
||||
public OffsetStream(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync, long start,
|
||||
long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(handle, access, bufferSize, isAsync);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, long start, long end)
|
||||
public OffsetStream(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize,
|
||||
FileOptions options, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode, rights, share, bufferSize, options);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, FileSecurity fileSecurity, long start, long end)
|
||||
public OffsetStream(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize,
|
||||
FileOptions options, FileSecurity fileSecurity, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode, rights, share, bufferSize, options, fileSecurity);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync, long start, long end)
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
|
||||
bool useAsync, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode, access, share, bufferSize, useAsync);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, long start, long end)
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, long start,
|
||||
long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode, access, share, bufferSize);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode, access, share);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, FileAccess access, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode, access);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(string path, FileMode mode, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new FileStream(path, mode);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible, long start, long end)
|
||||
public OffsetStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible, long start,
|
||||
long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new MemoryStream(buffer, index, count, writable, publiclyVisible);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(byte[] buffer, int index, int count, bool writable, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new MemoryStream(buffer, index, count, writable);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(byte[] buffer, int index, int count, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new MemoryStream(buffer, index, count);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(byte[] buffer, bool writable, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new MemoryStream(buffer, writable);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
public OffsetStream(byte[] buffer, long start, long end)
|
||||
{
|
||||
if(start < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), "Start can't be a negative number.");
|
||||
|
||||
if(end < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number.");
|
||||
|
||||
streamStart = start;
|
||||
streamEnd = end;
|
||||
|
||||
baseStream = new MemoryStream(buffer);
|
||||
|
||||
if(end > baseStream.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
if(end > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end.");
|
||||
}
|
||||
|
||||
~OffsetStream()
|
||||
@@ -343,64 +299,48 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseStream.CanRead;
|
||||
}
|
||||
get { return baseStream.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseStream.CanSeek;
|
||||
}
|
||||
get { return baseStream.CanSeek; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseStream.CanWrite;
|
||||
}
|
||||
get { return baseStream.CanWrite; }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return streamEnd - streamStart + 1;
|
||||
}
|
||||
get { return streamEnd - streamStart + 1; }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseStream.Position - streamStart;
|
||||
}
|
||||
get { return baseStream.Position - streamStart; }
|
||||
|
||||
set
|
||||
{
|
||||
if(value + streamStart > streamEnd)
|
||||
throw new IOException("Cannot set position past stream end.");
|
||||
if(value + streamStart > streamEnd) throw new IOException("Cannot set position past stream end.");
|
||||
|
||||
baseStream.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback,
|
||||
object state)
|
||||
{
|
||||
if(baseStream.Position + count > streamEnd)
|
||||
throw new IOException("Cannot read past stream end.");
|
||||
if(baseStream.Position + count > streamEnd) throw new IOException("Cannot read past stream end.");
|
||||
|
||||
return baseStream.BeginRead(buffer, offset, count, callback, state);
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback,
|
||||
object state)
|
||||
{
|
||||
if(baseStream.Position + count > streamEnd)
|
||||
throw new IOException("Cannot write past stream end.");
|
||||
if(baseStream.Position + count > streamEnd) throw new IOException("Cannot write past stream end.");
|
||||
|
||||
return baseStream.BeginWrite(buffer, offset, count, callback, state);
|
||||
}
|
||||
@@ -433,8 +373,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
if(baseStream.Position + 1 > streamEnd)
|
||||
throw new IOException("Cannot write past stream end.");
|
||||
if(baseStream.Position + 1 > streamEnd) throw new IOException("Cannot write past stream end.");
|
||||
|
||||
baseStream.WriteByte(value);
|
||||
}
|
||||
@@ -446,8 +385,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if(baseStream.Position + count > streamEnd + 1)
|
||||
throw new IOException("Cannot read past stream end.");
|
||||
if(baseStream.Position + count > streamEnd + 1) throw new IOException("Cannot read past stream end.");
|
||||
|
||||
return baseStream.Read(buffer, offset, count);
|
||||
}
|
||||
@@ -457,16 +395,17 @@ namespace DiscImageChef.Filters
|
||||
switch(origin)
|
||||
{
|
||||
case SeekOrigin.Begin:
|
||||
if(offset + streamStart > streamEnd)
|
||||
throw new IOException("Cannot seek past stream end.");
|
||||
if(offset + streamStart > streamEnd) throw new IOException("Cannot seek past stream end.");
|
||||
|
||||
return baseStream.Seek(offset + streamStart, SeekOrigin.Begin) - streamStart;
|
||||
case SeekOrigin.End:
|
||||
if(offset - (baseStream.Length - streamEnd) < streamStart)
|
||||
throw new IOException("Cannot seek before stream start.");
|
||||
|
||||
return baseStream.Seek(offset - (baseStream.Length - streamEnd), SeekOrigin.End) - streamStart;
|
||||
default:
|
||||
if(offset + baseStream.Position > streamEnd)
|
||||
throw new IOException("Cannot seek past stream end.");
|
||||
if(offset + baseStream.Position > streamEnd) throw new IOException("Cannot seek past stream end.");
|
||||
|
||||
return baseStream.Seek(offset, SeekOrigin.Current) - streamStart;
|
||||
}
|
||||
}
|
||||
@@ -478,11 +417,9 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if(baseStream.Position + count > streamEnd)
|
||||
throw new IOException("Cannot write past stream end.");
|
||||
if(baseStream.Position + count > streamEnd) throw new IOException("Cannot write past stream end.");
|
||||
|
||||
baseStream.Write(buffer, offset, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,8 +52,7 @@ 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>
|
||||
@@ -77,8 +76,7 @@ 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>
|
||||
@@ -100,8 +98,7 @@ 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>
|
||||
@@ -203,18 +200,17 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
string parentFolder = Path.GetDirectoryName(path);
|
||||
|
||||
if(!File.Exists(Path.Combine(parentFolder, FinderInfo)))
|
||||
return false;
|
||||
if(!File.Exists(Path.Combine(parentFolder, FinderInfo))) return false;
|
||||
|
||||
if(!Directory.Exists(Path.Combine(parentFolder, Resources)))
|
||||
return false;
|
||||
if(!Directory.Exists(Path.Combine(parentFolder, Resources))) return false;
|
||||
|
||||
string baseFilename = Path.GetFileName(path);
|
||||
|
||||
bool dataFound = false;
|
||||
bool rsrcFound = false;
|
||||
|
||||
FileStream finderDatStream = new FileStream(Path.Combine(parentFolder, FinderInfo), FileMode.Open, FileAccess.Read);
|
||||
FileStream finderDatStream =
|
||||
new FileStream(Path.Combine(parentFolder, FinderInfo), FileMode.Open, FileAccess.Read);
|
||||
|
||||
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
||||
{
|
||||
@@ -228,16 +224,18 @@ namespace DiscImageChef.Filters
|
||||
byte[] tmpDosExt_b = new byte[3];
|
||||
Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8);
|
||||
Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
|
||||
string dosName = (Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + Encoding.ASCII.GetString(tmpDosExt_b).Trim());
|
||||
string dosName = (Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." +
|
||||
Encoding.ASCII.GetString(tmpDosExt_b).Trim());
|
||||
string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture);
|
||||
|
||||
if(baseFilename == macName || baseFilename == dosName || baseFilename == dosNameLow)
|
||||
{
|
||||
dataFound |= File.Exists(Path.Combine(parentFolder, macName)) || File.Exists(Path.Combine(parentFolder, dosName)) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosNameLow));
|
||||
dataFound |= File.Exists(Path.Combine(parentFolder, macName)) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosName)) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosNameLow));
|
||||
|
||||
rsrcFound |= File.Exists(Path.Combine(parentFolder, Resources, dosName)) ||
|
||||
File.Exists(Path.Combine(parentFolder, Resources, dosNameLow));
|
||||
File.Exists(Path.Combine(parentFolder, Resources, dosNameLow));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -268,7 +266,8 @@ namespace DiscImageChef.Filters
|
||||
string parentFolder = Path.GetDirectoryName(path);
|
||||
string baseFilename = Path.GetFileName(path);
|
||||
|
||||
FileStream finderDatStream = new FileStream(Path.Combine(parentFolder, FinderInfo), FileMode.Open, FileAccess.Read);
|
||||
FileStream finderDatStream =
|
||||
new FileStream(Path.Combine(parentFolder, FinderInfo), FileMode.Open, FileAccess.Read);
|
||||
|
||||
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
||||
{
|
||||
@@ -281,26 +280,24 @@ namespace DiscImageChef.Filters
|
||||
byte[] tmpDosExt_b = new byte[3];
|
||||
Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8);
|
||||
Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
|
||||
string dosName = (Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + Encoding.ASCII.GetString(tmpDosExt_b).Trim());
|
||||
string dosName = (Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." +
|
||||
Encoding.ASCII.GetString(tmpDosExt_b).Trim());
|
||||
string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture);
|
||||
|
||||
if(baseFilename == macName || baseFilename == dosName || baseFilename == dosNameLow)
|
||||
{
|
||||
if(File.Exists(Path.Combine(parentFolder, macName)))
|
||||
dataPath = Path.Combine(parentFolder, macName);
|
||||
if(File.Exists(Path.Combine(parentFolder, macName))) dataPath = Path.Combine(parentFolder, macName);
|
||||
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);
|
||||
else
|
||||
dataPath = null;
|
||||
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);
|
||||
else
|
||||
rsrcPath = null;
|
||||
else rsrcPath = null;
|
||||
|
||||
lastWriteTime = DateHandlers.MacToDateTime(datEntry.modificationDate);
|
||||
creationTime = DateHandlers.MacToDateTime(datEntry.creationDate);
|
||||
@@ -318,4 +315,4 @@ namespace DiscImageChef.Filters
|
||||
finderDatStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,5 +54,4 @@ using System.Reflection;
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
@@ -54,8 +54,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if(dataStream != null)
|
||||
dataStream.Close();
|
||||
if(dataStream != null) dataStream.Close();
|
||||
dataStream = null;
|
||||
basePath = null;
|
||||
opened = false;
|
||||
@@ -88,7 +87,9 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override bool Identify(byte[] buffer)
|
||||
{
|
||||
return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 && buffer[4] == 0x5A && buffer[5] == 0x00 && buffer[buffer.Length - 2] == 0x59 && buffer[buffer.Length - 1] == 0x5A;
|
||||
return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 &&
|
||||
buffer[4] == 0x5A && buffer[5] == 0x00 && buffer[buffer.Length - 2] == 0x59 &&
|
||||
buffer[buffer.Length - 1] == 0x5A;
|
||||
}
|
||||
|
||||
public override bool Identify(Stream stream)
|
||||
@@ -102,7 +103,8 @@ namespace DiscImageChef.Filters
|
||||
stream.Read(footer, 0, 2);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 && buffer[4] == 0x5A && buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A;
|
||||
return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 &&
|
||||
buffer[4] == 0x5A && buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A;
|
||||
}
|
||||
|
||||
public override bool Identify(string path)
|
||||
@@ -120,7 +122,8 @@ namespace DiscImageChef.Filters
|
||||
stream.Read(footer, 0, 2);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 && buffer[4] == 0x5A && buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A;
|
||||
return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 &&
|
||||
buffer[4] == 0x5A && buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -155,19 +158,16 @@ namespace DiscImageChef.Filters
|
||||
|
||||
int Decode(byte[] buf, int size_max, ref ulong num)
|
||||
{
|
||||
if(size_max == 0)
|
||||
return 0;
|
||||
if(size_max == 0) return 0;
|
||||
|
||||
if(size_max > 9)
|
||||
size_max = 9;
|
||||
if(size_max > 9) size_max = 9;
|
||||
|
||||
num = (ulong)(buf[0] & 0x7F);
|
||||
int i = 0;
|
||||
|
||||
while((buf[i++] & 0x80) == 0x80)
|
||||
{
|
||||
if(i >= size_max || buf[i] == 0x00)
|
||||
return 0;
|
||||
if(i >= size_max || buf[i] == 0x00) return 0;
|
||||
|
||||
num |= (ulong)(buf[i] & 0x7F) << (i * 7);
|
||||
}
|
||||
@@ -240,12 +240,12 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override string GetFilename()
|
||||
{
|
||||
if(basePath == null)
|
||||
return null;
|
||||
if(basePath == null) return null;
|
||||
if(basePath.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 3);
|
||||
if(basePath.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase))
|
||||
return basePath.Substring(0, basePath.Length - 5);
|
||||
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if(dataStream != null)
|
||||
dataStream.Close();
|
||||
if(dataStream != null) dataStream.Close();
|
||||
dataStream = null;
|
||||
basePath = null;
|
||||
opened = false;
|
||||
@@ -167,5 +166,4 @@ namespace DiscImageChef.Filters
|
||||
return opened;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="SharpCompress" version="0.19.2" targetFramework="net40" />
|
||||
<package id="SharpCompress" version="0.19.2" targetFramework="net40" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user