mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: All refactor in DiscImageChef.Filters.
This commit is contained in:
@@ -180,7 +180,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override string GetFilename()
|
public override string GetFilename()
|
||||||
{
|
{
|
||||||
return basePath != null ? Path.GetFileName(basePath) : null;
|
return Path.GetFileName(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override DateTime GetLastWriteTime()
|
public override DateTime GetLastWriteTime()
|
||||||
@@ -380,10 +380,8 @@ namespace DiscImageChef.Filters
|
|||||||
unarStream.Read(unar_b, 0, 26);
|
unarStream.Read(unar_b, 0, 26);
|
||||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
header = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDoubleHeader>(unar_b);
|
||||||
unarStream.Close();
|
unarStream.Close();
|
||||||
if(header.magic == AppleDoubleMagic &&
|
return header.magic == AppleDoubleMagic &&
|
||||||
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) return true;
|
(header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2);
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsOpened()
|
public override bool IsOpened()
|
||||||
@@ -633,8 +631,7 @@ namespace DiscImageChef.Filters
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataFork = new AppleDoubleEntry();
|
dataFork = new AppleDoubleEntry {id = (uint)AppleDoubleEntryID.DataFork};
|
||||||
dataFork.id = (uint)AppleDoubleEntryID.DataFork;
|
|
||||||
if(File.Exists(path))
|
if(File.Exists(path))
|
||||||
{
|
{
|
||||||
FileStream dataFs = new FileStream(path, FileMode.Open, FileAccess.Read);
|
FileStream dataFs = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ namespace DiscImageChef.Filters
|
|||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
bytes = null;
|
bytes = null;
|
||||||
if(stream != null) stream.Close();
|
stream?.Close();
|
||||||
isBytes = false;
|
isBytes = false;
|
||||||
isStream = false;
|
isStream = false;
|
||||||
isPath = false;
|
isPath = false;
|
||||||
@@ -194,7 +194,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override string GetFilename()
|
public override string GetFilename()
|
||||||
{
|
{
|
||||||
return basePath != null ? Path.GetFileName(basePath) : null;
|
return Path.GetFileName(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override DateTime GetLastWriteTime()
|
public override DateTime GetLastWriteTime()
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if(dataStream != null) dataStream.Close();
|
dataStream?.Close();
|
||||||
dataStream = null;
|
dataStream = null;
|
||||||
basePath = null;
|
basePath = null;
|
||||||
opened = false;
|
opened = false;
|
||||||
@@ -93,10 +93,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
if(buffer.Length <= 512) return true;
|
if(buffer.Length <= 512) return true;
|
||||||
|
|
||||||
if(buffer[buffer.Length - 512] == 0x6B && buffer[buffer.Length - 511] == 0x6F &&
|
return buffer[buffer.Length - 512] != 0x6B || buffer[buffer.Length - 511] != 0x6F || buffer[buffer.Length - 510] != 0x6C || buffer[buffer.Length - 509] != 0x79;
|
||||||
buffer[buffer.Length - 510] == 0x6C && buffer[buffer.Length - 509] == 0x79) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Identify(Stream stream)
|
public override bool Identify(Stream stream)
|
||||||
@@ -116,9 +113,7 @@ namespace DiscImageChef.Filters
|
|||||||
stream.Read(buffer, 0, 4);
|
stream.Read(buffer, 0, 4);
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
// Check it is not an UDIF
|
// Check it is not an UDIF
|
||||||
if(buffer[0] == 0x6B && buffer[1] == 0x6F && buffer[2] == 0x6C && buffer[3] == 0x79) return false;
|
return buffer[0] != 0x6B || buffer[1] != 0x6F || buffer[2] != 0x6C || buffer[3] != 0x79;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Identify(string path)
|
public override bool Identify(string path)
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ namespace DiscImageChef.Filters
|
|||||||
{
|
{
|
||||||
public class FiltersList
|
public class FiltersList
|
||||||
{
|
{
|
||||||
public SortedDictionary<string, Filter> filtersList;
|
public SortedDictionary<string, Filter> Filters;
|
||||||
|
|
||||||
public FiltersList()
|
public FiltersList()
|
||||||
{
|
{
|
||||||
Assembly assembly = Assembly.GetAssembly(typeof(Filter));
|
Assembly assembly = Assembly.GetAssembly(typeof(Filter));
|
||||||
filtersList = new SortedDictionary<string, Filter>();
|
Filters = new SortedDictionary<string, Filter>();
|
||||||
|
|
||||||
foreach(Type type in assembly.GetTypes())
|
foreach(Type type in assembly.GetTypes())
|
||||||
try
|
try
|
||||||
@@ -52,7 +52,7 @@ namespace DiscImageChef.Filters
|
|||||||
if(!type.IsSubclassOf(typeof(Filter))) continue;
|
if(!type.IsSubclassOf(typeof(Filter))) continue;
|
||||||
|
|
||||||
Filter filter = (Filter)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
Filter filter = (Filter)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
||||||
if(filter != null && !filtersList.ContainsKey(filter.Name.ToLower())) filtersList.Add(filter.Name.ToLower(), filter);
|
if(filter != null && !Filters.ContainsKey(filter.Name.ToLower())) Filters.Add(filter.Name.ToLower(), filter);
|
||||||
}
|
}
|
||||||
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
|
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ namespace DiscImageChef.Filters
|
|||||||
{
|
{
|
||||||
Filter noFilter = null;
|
Filter noFilter = null;
|
||||||
|
|
||||||
foreach(Filter filter in filtersList.Values)
|
foreach(Filter filter in Filters.Values)
|
||||||
if(filter.UUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
if(filter.UUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
||||||
{
|
{
|
||||||
if(!filter.Identify(path)) continue;
|
if(!filter.Identify(path)) continue;
|
||||||
@@ -84,7 +84,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public SortedDictionary<string, Filter> GetFiltersList()
|
public SortedDictionary<string, Filter> GetFiltersList()
|
||||||
{
|
{
|
||||||
return filtersList;
|
return Filters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,9 +42,8 @@ namespace DiscImageChef.Filters
|
|||||||
public class ForcedSeekStream<T> : Stream where T : Stream
|
public class ForcedSeekStream<T> : Stream where T : Stream
|
||||||
{
|
{
|
||||||
T baseStream;
|
T baseStream;
|
||||||
object[] parameters;
|
|
||||||
long streamLength;
|
long streamLength;
|
||||||
const int bufferLen = 1048576;
|
const int BUFFER_LEN = 1048576;
|
||||||
FileStream backStream;
|
FileStream backStream;
|
||||||
string backFile;
|
string backFile;
|
||||||
|
|
||||||
@@ -55,9 +54,8 @@ namespace DiscImageChef.Filters
|
|||||||
/// <param name="args">Parameters that are used to create the base stream.</param>
|
/// <param name="args">Parameters that are used to create the base stream.</param>
|
||||||
public ForcedSeekStream(long length, params object[] args)
|
public ForcedSeekStream(long length, params object[] args)
|
||||||
{
|
{
|
||||||
parameters = args;
|
|
||||||
streamLength = length;
|
streamLength = length;
|
||||||
baseStream = (T)Activator.CreateInstance(typeof(T), parameters);
|
baseStream = (T)Activator.CreateInstance(typeof(T), args);
|
||||||
backFile = Path.GetTempFileName();
|
backFile = Path.GetTempFileName();
|
||||||
backStream = new FileStream(backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
backStream = new FileStream(backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||||
if(length == 0) CalculateLength();
|
if(length == 0) CalculateLength();
|
||||||
@@ -69,8 +67,7 @@ namespace DiscImageChef.Filters
|
|||||||
/// <param name="args">Parameters that are used to create the base stream.</param>
|
/// <param name="args">Parameters that are used to create the base stream.</param>
|
||||||
public ForcedSeekStream(params object[] args)
|
public ForcedSeekStream(params object[] args)
|
||||||
{
|
{
|
||||||
parameters = args;
|
baseStream = (T)Activator.CreateInstance(typeof(T), args);
|
||||||
baseStream = (T)Activator.CreateInstance(typeof(T), parameters);
|
|
||||||
backFile = Path.GetTempFileName();
|
backFile = Path.GetTempFileName();
|
||||||
backStream = new FileStream(backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
backStream = new FileStream(backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||||
CalculateLength();
|
CalculateLength();
|
||||||
@@ -87,41 +84,29 @@ namespace DiscImageChef.Filters
|
|||||||
int read;
|
int read;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[bufferLen];
|
byte[] buffer = new byte[BUFFER_LEN];
|
||||||
read = baseStream.Read(buffer, 0, bufferLen);
|
read = baseStream.Read(buffer, 0, BUFFER_LEN);
|
||||||
backStream.Write(buffer, 0, read);
|
backStream.Write(buffer, 0, read);
|
||||||
}
|
}
|
||||||
while(read == bufferLen);
|
while(read == BUFFER_LEN);
|
||||||
|
|
||||||
streamLength = backStream.Length;
|
streamLength = backStream.Length;
|
||||||
backStream.Position = 0;
|
backStream.Position = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanRead
|
public override bool CanRead => baseStream.CanRead;
|
||||||
{
|
|
||||||
get { return baseStream.CanRead; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSeek
|
public override bool CanSeek => true;
|
||||||
{
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanWrite
|
public override bool CanWrite => false;
|
||||||
{
|
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Length
|
public override long Length => streamLength;
|
||||||
{
|
|
||||||
get { return streamLength; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Position
|
public override long Position
|
||||||
{
|
{
|
||||||
get { return backStream.Position; }
|
get => backStream.Position;
|
||||||
|
|
||||||
set { SetPosition(value); }
|
set => SetPosition(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPosition(long position)
|
void SetPosition(long position)
|
||||||
@@ -136,15 +121,15 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
backStream.Position = backStream.Length;
|
backStream.Position = backStream.Length;
|
||||||
long toposition = position - backStream.Position;
|
long toposition = position - backStream.Position;
|
||||||
int fullBufferReads = (int)(toposition / bufferLen);
|
int fullBufferReads = (int)(toposition / BUFFER_LEN);
|
||||||
int restToRead = (int)(toposition % bufferLen);
|
int restToRead = (int)(toposition % BUFFER_LEN);
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
|
|
||||||
for(int i = 0; i < fullBufferReads; i++)
|
for(int i = 0; i < fullBufferReads; i++)
|
||||||
{
|
{
|
||||||
buffer = new byte[bufferLen];
|
buffer = new byte[BUFFER_LEN];
|
||||||
baseStream.Read(buffer, 0, bufferLen);
|
baseStream.Read(buffer, 0, BUFFER_LEN);
|
||||||
backStream.Write(buffer, 0, bufferLen);
|
backStream.Write(buffer, 0, BUFFER_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new byte[restToRead];
|
buffer = new byte[restToRead];
|
||||||
@@ -213,13 +198,13 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if(backStream != null) backStream.Close();
|
backStream?.Close();
|
||||||
File.Delete(backFile);
|
File.Delete(backFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ForcedSeekStream()
|
~ForcedSeekStream()
|
||||||
{
|
{
|
||||||
if(backStream != null) backStream.Close();
|
backStream?.Close();
|
||||||
File.Delete(backFile);
|
File.Delete(backFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if(dataStream != null) dataStream.Close();
|
dataStream?.Close();
|
||||||
dataStream = null;
|
dataStream = null;
|
||||||
basePath = null;
|
basePath = null;
|
||||||
opened = false;
|
opened = false;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if(dataStream != null) dataStream.Close();
|
dataStream?.Close();
|
||||||
dataStream = null;
|
dataStream = null;
|
||||||
basePath = null;
|
basePath = null;
|
||||||
opened = false;
|
opened = false;
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace DiscImageChef.Filters
|
|||||||
public short computerID;
|
public short computerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint MacBinaryMagic = 0x6D42494E;
|
const uint MACBINARY_MAGIC = 0x6D42494E;
|
||||||
|
|
||||||
long dataForkOff;
|
long dataForkOff;
|
||||||
long rsrcForkOff;
|
long rsrcForkOff;
|
||||||
@@ -183,7 +183,7 @@ namespace DiscImageChef.Filters
|
|||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
bytes = null;
|
bytes = null;
|
||||||
if(stream != null) stream.Close();
|
stream?.Close();
|
||||||
isBytes = false;
|
isBytes = false;
|
||||||
isStream = false;
|
isStream = false;
|
||||||
isPath = false;
|
isPath = false;
|
||||||
@@ -274,7 +274,7 @@ namespace DiscImageChef.Filters
|
|||||||
Array.Copy(buffer, 0, hdr_b, 0, 128);
|
Array.Copy(buffer, 0, hdr_b, 0, 128);
|
||||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||||
|
|
||||||
return header.magic == MacBinaryMagic || header.version == 0 && header.filename[0] > 0 &&
|
return header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
|
||||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||||
header.zero2 == 0 && header.reserved == 0 &&
|
header.zero2 == 0 && header.reserved == 0 &&
|
||||||
(header.dataLength > 0 || header.resourceLength > 0);
|
(header.dataLength > 0 || header.resourceLength > 0);
|
||||||
@@ -289,7 +289,7 @@ namespace DiscImageChef.Filters
|
|||||||
stream.Read(hdr_b, 0, 128);
|
stream.Read(hdr_b, 0, 128);
|
||||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||||
|
|
||||||
return header.magic == MacBinaryMagic || header.version == 0 && header.filename[0] > 0 &&
|
return header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
|
||||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||||
header.zero2 == 0 && header.reserved == 0 &&
|
header.zero2 == 0 && header.reserved == 0 &&
|
||||||
(header.dataLength > 0 || header.resourceLength > 0);
|
(header.dataLength > 0 || header.resourceLength > 0);
|
||||||
@@ -305,7 +305,7 @@ namespace DiscImageChef.Filters
|
|||||||
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
header = BigEndianMarshal.ByteArrayToStructureBigEndian<MacBinaryHeader>(hdr_b);
|
||||||
|
|
||||||
fstream.Close();
|
fstream.Close();
|
||||||
return header.magic == MacBinaryMagic || header.version == 0 && header.filename[0] > 0 &&
|
return header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
|
||||||
header.filename[0] < 64 && header.zero1 == 0 &&
|
header.filename[0] < 64 && header.zero1 == 0 &&
|
||||||
header.zero2 == 0 && header.reserved == 0 &&
|
header.zero2 == 0 && header.reserved == 0 &&
|
||||||
(header.dataLength > 0 || header.resourceLength > 0);
|
(header.dataLength > 0 || header.resourceLength > 0);
|
||||||
|
|||||||
@@ -297,29 +297,17 @@ namespace DiscImageChef.Filters
|
|||||||
baseStream.Dispose();
|
baseStream.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanRead
|
public override bool CanRead => baseStream.CanRead;
|
||||||
{
|
|
||||||
get { return baseStream.CanRead; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSeek
|
public override bool CanSeek => baseStream.CanSeek;
|
||||||
{
|
|
||||||
get { return baseStream.CanSeek; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanWrite
|
public override bool CanWrite => baseStream.CanWrite;
|
||||||
{
|
|
||||||
get { return baseStream.CanWrite; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Length
|
public override long Length => streamEnd - streamStart + 1;
|
||||||
{
|
|
||||||
get { return streamEnd - streamStart + 1; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Position
|
public override long Position
|
||||||
{
|
{
|
||||||
get { return baseStream.Position - streamStart; }
|
get => baseStream.Position - streamStart;
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ namespace DiscImageChef.Filters
|
|||||||
{
|
{
|
||||||
public class PCExchange : Filter
|
public class PCExchange : Filter
|
||||||
{
|
{
|
||||||
const string FileId = "FILEID.DAT";
|
const string FILE_ID = "FILEID.DAT";
|
||||||
const string FinderInfo = "FINDER.DAT";
|
const string FINDER_INFO = "FINDER.DAT";
|
||||||
const string Resources = "RESOURCE.FRK";
|
const string RESOURCES = "RESOURCE.FRK";
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
struct PCExchangeEntry
|
struct PCExchangeEntry
|
||||||
@@ -147,7 +147,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override string GetFilename()
|
public override string GetFilename()
|
||||||
{
|
{
|
||||||
return basePath != null ? Path.GetFileName(basePath) : null;
|
return Path.GetFileName(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override DateTime GetLastWriteTime()
|
public override DateTime GetLastWriteTime()
|
||||||
@@ -200,9 +200,9 @@ namespace DiscImageChef.Filters
|
|||||||
{
|
{
|
||||||
string parentFolder = Path.GetDirectoryName(path);
|
string parentFolder = Path.GetDirectoryName(path);
|
||||||
|
|
||||||
if(!File.Exists(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FinderInfo))) return false;
|
if(!File.Exists(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FINDER_INFO))) 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);
|
string baseFilename = Path.GetFileName(path);
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ namespace DiscImageChef.Filters
|
|||||||
bool rsrcFound = false;
|
bool rsrcFound = false;
|
||||||
|
|
||||||
FileStream finderDatStream =
|
FileStream finderDatStream =
|
||||||
new FileStream(Path.Combine(parentFolder, FinderInfo), FileMode.Open, FileAccess.Read);
|
new FileStream(Path.Combine(parentFolder, FINDER_INFO), FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
||||||
{
|
{
|
||||||
@@ -234,8 +234,8 @@ namespace DiscImageChef.Filters
|
|||||||
File.Exists(Path.Combine(parentFolder, dosName)) ||
|
File.Exists(Path.Combine(parentFolder, dosName)) ||
|
||||||
File.Exists(Path.Combine(parentFolder, dosNameLow));
|
File.Exists(Path.Combine(parentFolder, dosNameLow));
|
||||||
|
|
||||||
rsrcFound |= File.Exists(Path.Combine(parentFolder, Resources, dosName)) ||
|
rsrcFound |= File.Exists(Path.Combine(parentFolder, RESOURCES, dosName)) ||
|
||||||
File.Exists(Path.Combine(parentFolder, Resources, dosNameLow));
|
File.Exists(Path.Combine(parentFolder, RESOURCES, dosNameLow));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ namespace DiscImageChef.Filters
|
|||||||
string baseFilename = Path.GetFileName(path);
|
string baseFilename = Path.GetFileName(path);
|
||||||
|
|
||||||
FileStream finderDatStream =
|
FileStream finderDatStream =
|
||||||
new FileStream(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FinderInfo), FileMode.Open, FileAccess.Read);
|
new FileStream(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FINDER_INFO), FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
||||||
{
|
{
|
||||||
@@ -292,10 +292,10 @@ namespace DiscImageChef.Filters
|
|||||||
dataPath = Path.Combine(parentFolder, dosNameLow);
|
dataPath = Path.Combine(parentFolder, dosNameLow);
|
||||||
else dataPath = null;
|
else dataPath = null;
|
||||||
|
|
||||||
if(File.Exists(Path.Combine(parentFolder, Resources, dosName)))
|
if(File.Exists(Path.Combine(parentFolder, RESOURCES, dosName)))
|
||||||
rsrcPath = Path.Combine(parentFolder, Resources, dosName);
|
rsrcPath = Path.Combine(parentFolder, RESOURCES, dosName);
|
||||||
else if(File.Exists(Path.Combine(parentFolder, Resources, dosNameLow)))
|
else if(File.Exists(Path.Combine(parentFolder, RESOURCES, dosNameLow)))
|
||||||
rsrcPath = Path.Combine(parentFolder, Resources, dosNameLow);
|
rsrcPath = Path.Combine(parentFolder, RESOURCES, dosNameLow);
|
||||||
else rsrcPath = null;
|
else rsrcPath = null;
|
||||||
|
|
||||||
lastWriteTime = DateHandlers.MacToDateTime(datEntry.modificationDate);
|
lastWriteTime = DateHandlers.MacToDateTime(datEntry.modificationDate);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if(dataStream != null) dataStream.Close();
|
dataStream?.Close();
|
||||||
dataStream = null;
|
dataStream = null;
|
||||||
basePath = null;
|
basePath = null;
|
||||||
opened = false;
|
opened = false;
|
||||||
@@ -153,18 +153,18 @@ namespace DiscImageChef.Filters
|
|||||||
dataStream.Seek(0, SeekOrigin.Begin);
|
dataStream.Seek(0, SeekOrigin.Begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Decode(byte[] buf, int size_max, ref ulong num)
|
int Decode(byte[] buf, int sizeMax, ref ulong num)
|
||||||
{
|
{
|
||||||
if(size_max == 0) return 0;
|
if(sizeMax == 0) return 0;
|
||||||
|
|
||||||
if(size_max > 9) size_max = 9;
|
if(sizeMax > 9) sizeMax = 9;
|
||||||
|
|
||||||
num = (ulong)(buf[0] & 0x7F);
|
num = (ulong)(buf[0] & 0x7F);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while((buf[i++] & 0x80) == 0x80)
|
while((buf[i++] & 0x80) == 0x80)
|
||||||
{
|
{
|
||||||
if(i >= size_max || buf[i] == 0x00) return 0;
|
if(i >= sizeMax || buf[i] == 0x00) return 0;
|
||||||
|
|
||||||
num |= (ulong)(buf[i] & 0x7F) << (i * 7);
|
num |= (ulong)(buf[i] & 0x7F) << (i * 7);
|
||||||
}
|
}
|
||||||
@@ -239,10 +239,7 @@ namespace DiscImageChef.Filters
|
|||||||
{
|
{
|
||||||
if(basePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true)
|
if(basePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true)
|
||||||
return basePath.Substring(0, basePath.Length - 3);
|
return basePath.Substring(0, basePath.Length - 3);
|
||||||
if(basePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true)
|
return basePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true ? basePath.Substring(0, basePath.Length - 5) : basePath;
|
||||||
return basePath.Substring(0, basePath.Length - 5);
|
|
||||||
|
|
||||||
return basePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetParentFolder()
|
public override string GetParentFolder()
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if(dataStream != null) dataStream.Close();
|
dataStream?.Close();
|
||||||
dataStream = null;
|
dataStream = null;
|
||||||
basePath = null;
|
basePath = null;
|
||||||
opened = false;
|
opened = false;
|
||||||
@@ -153,7 +153,7 @@ namespace DiscImageChef.Filters
|
|||||||
|
|
||||||
public override string GetFilename()
|
public override string GetFilename()
|
||||||
{
|
{
|
||||||
return basePath != null ? Path.GetFileName(basePath) : null;
|
return Path.GetFileName(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetParentFolder()
|
public override string GetParentFolder()
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
DicConsole.WriteLine("Supported filters:");
|
DicConsole.WriteLine("Supported filters:");
|
||||||
if(formatsOptions.Verbose) DicConsole.VerboseWriteLine("GUID\t\t\t\t\tFilter");
|
if(formatsOptions.Verbose) DicConsole.VerboseWriteLine("GUID\t\t\t\t\tFilter");
|
||||||
foreach(KeyValuePair<string, Filter> kvp in filtersList.filtersList)
|
foreach(KeyValuePair<string, Filter> kvp in filtersList.Filters)
|
||||||
if(formatsOptions.Verbose) DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.UUID, kvp.Value.Name);
|
if(formatsOptions.Verbose) DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.UUID, kvp.Value.Name);
|
||||||
else DicConsole.WriteLine(kvp.Value.Name);
|
else DicConsole.WriteLine(kvp.Value.Name);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user