🎨Converted all plugin types to interfaces.

This commit is contained in:
2017-12-26 06:05:12 +00:00
parent a002253fa4
commit f66a0bdd42
295 changed files with 9499 additions and 10414 deletions

View File

@@ -40,7 +40,7 @@ namespace DiscImageChef.Filters
/// <summary>
/// Decompress bz2 files while reading
/// </summary>
public class BZip2 : Filter
public class BZip2 : IFilter
{
string basePath;
DateTime creationTime;
@@ -50,13 +50,10 @@ namespace DiscImageChef.Filters
DateTime lastWriteTime;
bool opened;
public BZip2()
{
Name = "BZip2";
UUID = new Guid("FCCFB0C3-32EF-40D8-9714-2333F6AC72A9");
}
public virtual string Name => "BZip2";
public virtual Guid Id => new Guid("FCCFB0C3-32EF-40D8-9714-2333F6AC72A9");
public override void Close()
public virtual void Close()
{
dataStream?.Close();
dataStream = null;
@@ -64,32 +61,32 @@ namespace DiscImageChef.Filters
opened = false;
}
public override string GetBasePath()
public virtual string GetBasePath()
{
return basePath;
}
public override Stream GetDataForkStream()
public virtual Stream GetDataForkStream()
{
return innerStream;
}
public override string GetPath()
public virtual string GetPath()
{
return basePath;
}
public override Stream GetResourceForkStream()
public virtual Stream GetResourceForkStream()
{
return null;
}
public override bool HasResourceFork()
public virtual bool HasResourceFork()
{
return false;
}
public override bool Identify(byte[] buffer)
public virtual bool Identify(byte[] buffer)
{
if(buffer[0] != 0x42 || buffer[1] != 0x5A || buffer[2] != 0x68 || buffer[3] < 0x31 ||
buffer[3] > 0x39) return false;
@@ -100,7 +97,7 @@ namespace DiscImageChef.Filters
buffer[buffer.Length - 510] != 0x6C || buffer[buffer.Length - 509] != 0x79;
}
public override bool Identify(Stream stream)
public virtual bool Identify(Stream stream)
{
byte[] buffer = new byte[4];
@@ -120,7 +117,7 @@ namespace DiscImageChef.Filters
return buffer[0] != 0x6B || buffer[1] != 0x6F || buffer[2] != 0x6C || buffer[3] != 0x79;
}
public override bool Identify(string path)
public virtual bool Identify(string path)
{
if(!File.Exists(path)) return false;
@@ -145,7 +142,7 @@ namespace DiscImageChef.Filters
return true;
}
public override void Open(byte[] buffer)
public virtual void Open(byte[] buffer)
{
dataStream = new MemoryStream(buffer);
basePath = null;
@@ -156,7 +153,7 @@ namespace DiscImageChef.Filters
opened = true;
}
public override void Open(Stream stream)
public virtual void Open(Stream stream)
{
dataStream = stream;
basePath = null;
@@ -167,7 +164,7 @@ namespace DiscImageChef.Filters
opened = true;
}
public override void Open(string path)
public virtual void Open(string path)
{
dataStream = new FileStream(path, FileMode.Open, FileAccess.Read);
basePath = Path.GetFullPath(path);
@@ -183,32 +180,32 @@ namespace DiscImageChef.Filters
opened = true;
}
public override DateTime GetCreationTime()
public virtual DateTime GetCreationTime()
{
return creationTime;
}
public override long GetDataForkLength()
public virtual long GetDataForkLength()
{
return decompressedSize;
}
public override DateTime GetLastWriteTime()
public virtual DateTime GetLastWriteTime()
{
return lastWriteTime;
}
public override long GetLength()
public virtual long GetLength()
{
return decompressedSize;
}
public override long GetResourceForkLength()
public virtual long GetResourceForkLength()
{
return 0;
}
public override string GetFilename()
public virtual string GetFilename()
{
if(basePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true)
return basePath.Substring(0, basePath.Length - 4);
@@ -218,12 +215,12 @@ namespace DiscImageChef.Filters
return basePath;
}
public override string GetParentFolder()
public virtual string GetParentFolder()
{
return Path.GetDirectoryName(basePath);
}
public override bool IsOpened()
public virtual bool IsOpened()
{
return opened;
}