mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 11:14:23 +00:00
Some cleanup around FileTypes
This commit is contained in:
@@ -209,12 +209,6 @@ Below are originally from SabreTools / DATabase -
|
||||
4 bytes of the SHA-1, 1 byte for each layer of the directory name. It also
|
||||
includes two auxilary files, .romba_size and .romba_size.backup, that have the
|
||||
compressed size of the folder inside for use with Romba.
|
||||
|
||||
-tlrz Enable Torrent Long-Range Zip output [NOT IMPLEMENTED]
|
||||
Instead of ouputting the files to folder, files will be rebuilt to Torrent Long-Range
|
||||
Zip (TLRZ) files. This format is based on the LRZip file format as defined at
|
||||
https://github.com/ckolivas/lrzip but with custom header information. This is currently
|
||||
unused by any major application.
|
||||
|
||||
-trar Enable Torrent RAR output [NOT IMPLEMENTED]
|
||||
Instead of outputting files to folder, files will be rebuilt to Torrent RAR (TRAR)
|
||||
|
||||
@@ -130,22 +130,25 @@ namespace SabreTools.DatItems
|
||||
/// <returns>DatItem of the specific internal type that corresponds to the inputs</returns>
|
||||
public static DatItem? Create(BaseFile? baseFile)
|
||||
{
|
||||
return baseFile?.Type switch
|
||||
return baseFile switch
|
||||
{
|
||||
FileType.AaruFormat => new Media(baseFile),
|
||||
FileType.CHD => new Disk(baseFile),
|
||||
FileType.GZipArchive => new Rom(baseFile),
|
||||
FileType.LRZipArchive => new Rom(baseFile),
|
||||
FileType.LZ4Archive => new Rom(baseFile),
|
||||
FileType.None => new Rom(baseFile),
|
||||
FileType.RarArchive => new Rom(baseFile),
|
||||
FileType.SevenZipArchive => new Rom(baseFile),
|
||||
FileType.TapeArchive => new Rom(baseFile),
|
||||
FileType.XZArchive => new Rom(baseFile),
|
||||
FileType.ZipArchive => new Rom(baseFile),
|
||||
FileType.ZPAQArchive => new Rom(baseFile),
|
||||
FileType.ZstdArchive => new Rom(baseFile),
|
||||
_ => null,
|
||||
// Disk
|
||||
FileTypes.CHD.CHDFile => new Disk(baseFile),
|
||||
|
||||
// Media
|
||||
FileTypes.Aaru.AaruFormat => new Media(baseFile),
|
||||
|
||||
// Rom
|
||||
FileTypes.Archives.GZipArchive => new Rom(baseFile),
|
||||
FileTypes.Archives.RarArchive => new Rom(baseFile),
|
||||
FileTypes.Archives.SevenZipArchive => new Rom(baseFile),
|
||||
FileTypes.Archives.TapeArchive => new Rom(baseFile),
|
||||
FileTypes.Archives.XZArchive => new Rom(baseFile),
|
||||
FileTypes.Archives.ZipArchive => new Rom(baseFile),
|
||||
|
||||
// Miscellaneous
|
||||
null => null,
|
||||
_ => new Rom(baseFile),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -332,15 +332,15 @@ namespace SabreTools.DatTools
|
||||
if (internalFileInfo == null)
|
||||
internalDatItem = null;
|
||||
#if NETFRAMEWORK
|
||||
else if (internalFileInfo.Type == FileType.AaruFormat && (asFiles & TreatAsFile.AaruFormat) == 0)
|
||||
else if (internalFileInfo is FileTypes.Aaru.AaruFormat && (asFiles & TreatAsFile.AaruFormat) == 0)
|
||||
#else
|
||||
else if (internalFileInfo.Type == FileType.AaruFormat && !asFiles.HasFlag(TreatAsFile.AaruFormat))
|
||||
else if (internalFileInfo is FileTypes.Aaru.AaruFormat && !asFiles.HasFlag(TreatAsFile.AaruFormat))
|
||||
#endif
|
||||
internalDatItem = new Media(internalFileInfo);
|
||||
#if NETFRAMEWORK
|
||||
else if (internalFileInfo.Type == FileType.CHD && (asFiles & TreatAsFile.CHD) == 0)
|
||||
else if (internalFileInfo is FileTypes.CHD.CHDFile && (asFiles & TreatAsFile.CHD) == 0)
|
||||
#else
|
||||
else if (internalFileInfo.Type == FileType.CHD && !asFiles.HasFlag(TreatAsFile.CHD))
|
||||
else if (internalFileInfo is FileTypes.CHD.CHDFile && !asFiles.HasFlag(TreatAsFile.CHD))
|
||||
#endif
|
||||
internalDatItem = new Disk(internalFileInfo);
|
||||
else
|
||||
@@ -851,7 +851,6 @@ namespace SabreTools.DatTools
|
||||
OutputFormat.Torrent7Zip => "Torrent7Z",
|
||||
OutputFormat.TorrentGzip => "TorrentGZ",
|
||||
OutputFormat.TorrentGzipRomba => "TorrentGZ",
|
||||
OutputFormat.TorrentLRZip => "TorrentLRZ",
|
||||
OutputFormat.TorrentRar => "TorrentRAR",
|
||||
OutputFormat.TorrentXZ => "TorrentXZ",
|
||||
OutputFormat.TorrentXZRomba => "TorrentXZ",
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace SabreTools.FileTypes.Aaru
|
||||
/// </summary>
|
||||
public AaruFormat()
|
||||
{
|
||||
Type = FileType.AaruFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,12 +70,8 @@ namespace SabreTools.FileTypes.Aaru
|
||||
if (!validated)
|
||||
return null;
|
||||
|
||||
// Read and retrun the current AaruFormat
|
||||
AaruFormat? generated = Deserialize(aarustream);
|
||||
if (generated != null)
|
||||
generated.Type = FileType.AaruFormat;
|
||||
|
||||
return generated;
|
||||
// Read and return the current AaruFormat
|
||||
return Deserialize(aarustream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -55,7 +55,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public GZipArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.GZipArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +66,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public GZipArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.GZipArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.FileTypes.Archives
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a TorrentLRZip archive for reading and writing
|
||||
/// </summary>
|
||||
/// TODO: Implement from source at https://github.com/ckolivas/lrzip
|
||||
public class LRZipArchive : BaseArchive
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a new LRZipArchive with no base file
|
||||
/// </summary>
|
||||
public LRZipArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.LRZipArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new LRZipArchive from the given file
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to use as an archive</param>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||
public LRZipArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.LRZipArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extraction
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool CopyAll(string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string CopyToFile(string entryName, string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (Stream?, string?) GetEntryStream(string entryName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Information
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool IsTorrent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Writing
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(string inputFile, string outDir, BaseFile? baseFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(Stream? inputStream, string outDir, BaseFile? baseFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(List<string> inputFiles, string outDir, List<BaseFile>? baseFiles)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.FileTypes.Archives
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a TorrentLRZip archive for reading and writing
|
||||
/// </summary>
|
||||
/// TODO: Implement from source at https://github.com/lz4/lz4
|
||||
public class LZ4Archive : BaseArchive
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a new LZ4Archive with no base file
|
||||
/// </summary>
|
||||
public LZ4Archive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.LZ4Archive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new LZ4Archive from the given file
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to use as an archive</param>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||
public LZ4Archive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.LZ4Archive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extraction
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool CopyAll(string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string CopyToFile(string entryName, string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (Stream?, string?) GetEntryStream(string entryName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Information
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool IsTorrent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Writing
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(string inputFile, string outDir, BaseFile? rom)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(Stream? inputStream, string outDir, BaseFile? rom)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(List<string> inputFiles, string outDir, List<BaseFile>? baseFiles)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public RarArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.RarArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -37,7 +36,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public RarArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.RarArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -71,7 +71,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public SevenZipArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.SevenZipArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,7 +82,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public SevenZipArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.SevenZipArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public TapeArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.TapeArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +41,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public TapeArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.TapeArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public XZArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.XZArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +57,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public XZArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.XZArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.FileTypes.Archives
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ZPAQArchive archive for reading and writing
|
||||
/// </summary>
|
||||
/// TODO: Implement from source at https://github.com/zpaq/zpaq - In progress as external DLL
|
||||
public class ZPAQArchive : BaseArchive
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ZPAQArchive with no base file
|
||||
/// </summary>
|
||||
public ZPAQArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.ZPAQArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ZPAQArchive from the given file
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to use as an archive</param>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||
public ZPAQArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.ZPAQArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extraction
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool CopyAll(string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string CopyToFile(string entryName, string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (Stream?, string?) GetEntryStream(string entryName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Information
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool IsTorrent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Writing
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(string inputFile, string outDir, BaseFile? baseFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(Stream? inputStream, string outDir, BaseFile? baseFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(List<string> inputFiles, string outDir, List<BaseFile>? baseFiles)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public ZipArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.ZipArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -63,7 +62,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
public ZipArchive(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.ZipArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.FileTypes.Archives
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ZstdArchive archive for reading and writing
|
||||
/// </summary>
|
||||
/// TODO: Implement from source at https://github.com/skbkontur/ZstdNet
|
||||
public class ZstdArchive : BaseArchive
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ZstdArchive with no base file
|
||||
/// </summary>
|
||||
public ZstdArchive()
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.ZstdArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ZstdArchive from the given file
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to use as an archive</param>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||
public ZstdArchive(string filename, bool getHashes)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.ZstdArchive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extraction
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool CopyAll(string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string CopyToFile(string entryName, string outDir)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override (Stream?, string?) GetEntryStream(string entryName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Information
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool IsTorrent()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Writing
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(string inputFile, string outDir, BaseFile? baseFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(Stream? inputStream, string outDir, BaseFile? baseFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Write(List<string> inputFiles, string outDir, List<BaseFile>? baseFiles)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -14,40 +14,29 @@ namespace SabreTools.FileTypes
|
||||
{
|
||||
#region Constants
|
||||
|
||||
protected static readonly byte[] SevenZipSignature = { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c };
|
||||
protected static readonly byte[] AaruFormatSignature = { 0x41, 0x41, 0x52, 0x55, 0x46, 0x52, 0x4d, 0x54 };
|
||||
protected static readonly byte[] BZ2Signature = { 0x42, 0x5a, 0x68 };
|
||||
protected static readonly byte[] CabinetSignature = { 0x4d, 0x53, 0x43, 0x46 };
|
||||
protected static readonly byte[] CHDSignature = { 0x4d, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x48, 0x44 };
|
||||
protected static readonly byte[] ELFSignature = { 0x7f, 0x45, 0x4c, 0x46 };
|
||||
protected static readonly byte[] FreeArcSignature = { 0x41, 0x72, 0x43, 0x01 };
|
||||
protected static readonly byte[] GzSignature = { 0x1f, 0x8b, 0x08 };
|
||||
protected static readonly byte[] LRZipSignature = { 0x4c, 0x52, 0x5a, 0x49 };
|
||||
protected static readonly byte[] LZ4Signature = { 0x18, 0x4d, 0x22, 0x04 };
|
||||
protected static readonly byte[] LZ4SkippableMinSignature = { 0x18, 0x4d, 0x22, 0x04 };
|
||||
protected static readonly byte[] LZ4SkippableMaxSignature = { 0x18, 0x4d, 0x2a, 0x5f };
|
||||
protected static readonly byte[] PESignature = { 0x4d, 0x5a };
|
||||
protected static readonly byte[] RarSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
|
||||
protected static readonly byte[] RarFiveSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 };
|
||||
protected static readonly byte[] TarSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00 };
|
||||
protected static readonly byte[] TarZeroSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 };
|
||||
protected static readonly byte[] XZSignature = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00 };
|
||||
protected static readonly byte[] ZipSignature = { 0x50, 0x4b, 0x03, 0x04 };
|
||||
protected static readonly byte[] ZipSignatureEmpty = { 0x50, 0x4b, 0x05, 0x06 };
|
||||
protected static readonly byte[] ZipSignatureSpanned = { 0x50, 0x4b, 0x07, 0x08 };
|
||||
protected static readonly byte[] ZPAQSignature = { 0x7a, 0x50, 0x51 };
|
||||
protected static readonly byte[] ZstdSignature = { 0xfd, 0x2f, 0xb5 };
|
||||
protected static readonly byte[] SevenZipSignature = [0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c];
|
||||
protected static readonly byte[] AaruFormatSignature = [0x41, 0x41, 0x52, 0x55, 0x46, 0x52, 0x4d, 0x54];
|
||||
protected static readonly byte[] BZ2Signature = [0x42, 0x5a, 0x68];
|
||||
protected static readonly byte[] CabinetSignature = [0x4d, 0x53, 0x43, 0x46];
|
||||
protected static readonly byte[] CHDSignature = [0x4d, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x48, 0x44];
|
||||
protected static readonly byte[] ELFSignature = [0x7f, 0x45, 0x4c, 0x46];
|
||||
protected static readonly byte[] FreeArcSignature = [0x41, 0x72, 0x43, 0x01];
|
||||
protected static readonly byte[] GzSignature = [0x1f, 0x8b, 0x08];
|
||||
protected static readonly byte[] PESignature = [0x4d, 0x5a];
|
||||
protected static readonly byte[] RarSignature = [0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00];
|
||||
protected static readonly byte[] RarFiveSignature = [0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00];
|
||||
protected static readonly byte[] TarSignature = [0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00];
|
||||
protected static readonly byte[] TarZeroSignature = [0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30];
|
||||
protected static readonly byte[] XZSignature = [0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00];
|
||||
protected static readonly byte[] ZipSignature = [0x50, 0x4b, 0x03, 0x04];
|
||||
protected static readonly byte[] ZipSignatureEmpty = [0x50, 0x4b, 0x05, 0x06];
|
||||
protected static readonly byte[] ZipSignatureSpanned = [0x50, 0x4b, 0x07, 0x08];
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Get all of these values automatically so there is no public "set"
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Internal type of the represented file
|
||||
/// </summary>
|
||||
public FileType Type { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Filename or path to the file
|
||||
/// </summary>
|
||||
@@ -220,16 +209,6 @@ namespace SabreTools.FileTypes
|
||||
{
|
||||
outFileType = FileType.GZipArchive;
|
||||
}
|
||||
else if (magic.StartsWith(LRZipSignature))
|
||||
{
|
||||
outFileType = FileType.LRZipArchive;
|
||||
}
|
||||
else if (magic.StartsWith(LZ4Signature)
|
||||
|| magic.StartsWith(LZ4SkippableMinSignature)
|
||||
|| magic.StartsWith(LZ4SkippableMaxSignature))
|
||||
{
|
||||
outFileType = FileType.LZ4Archive;
|
||||
}
|
||||
else if (magic.StartsWith(RarSignature)
|
||||
|| magic.StartsWith(RarFiveSignature))
|
||||
{
|
||||
@@ -250,14 +229,6 @@ namespace SabreTools.FileTypes
|
||||
{
|
||||
outFileType = FileType.ZipArchive;
|
||||
}
|
||||
else if (magic.StartsWith(ZPAQSignature))
|
||||
{
|
||||
outFileType = FileType.ZPAQArchive;
|
||||
}
|
||||
else if (magic.StartsWith(ZstdSignature))
|
||||
{
|
||||
outFileType = FileType.ZstdArchive;
|
||||
}
|
||||
|
||||
return outFileType;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace SabreTools.FileTypes.CHD
|
||||
if (validatedVersion == 0)
|
||||
return null;
|
||||
|
||||
// Read and retrun the current CHD
|
||||
// Read and return the current CHD
|
||||
CHDFile? generated = ReadAsVersion(chdstream, version);
|
||||
if (generated != null)
|
||||
generated.Type = FileType.CHD;
|
||||
|
||||
@@ -1274,14 +1274,10 @@ namespace SabreTools.FileTypes
|
||||
Folder,
|
||||
SevenZipArchive,
|
||||
GZipArchive,
|
||||
LRZipArchive,
|
||||
LZ4Archive,
|
||||
RarArchive,
|
||||
TapeArchive,
|
||||
XZArchive,
|
||||
ZipArchive,
|
||||
ZPAQArchive,
|
||||
ZstdArchive,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1302,10 +1298,6 @@ namespace SabreTools.FileTypes
|
||||
// Currently unimplemented fully
|
||||
Torrent7Zip,
|
||||
TorrentRar,
|
||||
TorrentLRZip,
|
||||
TorrentLZ4,
|
||||
TorrentZstd,
|
||||
TorrentZPAQ,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace SabreTools.FileTypes
|
||||
public Folder(bool writeToParent = false)
|
||||
: base()
|
||||
{
|
||||
this.Type = FileType.Folder;
|
||||
this.writeToParent = writeToParent;
|
||||
logger = new Logger(this);
|
||||
}
|
||||
@@ -59,7 +58,6 @@ namespace SabreTools.FileTypes
|
||||
public Folder(string filename, bool getHashes = false)
|
||||
: base(filename, getHashes)
|
||||
{
|
||||
this.Type = FileType.Folder;
|
||||
logger = new Logger(this);
|
||||
}
|
||||
|
||||
@@ -78,14 +76,10 @@ namespace SabreTools.FileTypes
|
||||
OutputFormat.Torrent7Zip => new SevenZipArchive(),
|
||||
OutputFormat.TorrentGzip => new GZipArchive(),
|
||||
OutputFormat.TorrentGzipRomba => new GZipArchive(),
|
||||
OutputFormat.TorrentLRZip => new LRZipArchive(),
|
||||
OutputFormat.TorrentLZ4 => new LZ4Archive(),
|
||||
OutputFormat.TorrentRar => new RarArchive(),
|
||||
OutputFormat.TorrentXZ => new XZArchive(),
|
||||
OutputFormat.TorrentXZRomba => new XZArchive(),
|
||||
OutputFormat.TorrentZip => new ZipArchive(),
|
||||
OutputFormat.TorrentZPAQ => new ZPAQArchive(),
|
||||
OutputFormat.TorrentZstd => new ZstdArchive(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1953,20 +1953,12 @@ Some special strings that can be used:
|
||||
return OutputFormat.Torrent7Zip;
|
||||
else if (GetBoolean(features, TorrentGzipValue))
|
||||
return OutputFormat.TorrentGzip;
|
||||
//else if (GetBoolean(features, SharedTorrentLrzipValue))
|
||||
// return OutputFormat.TorrentLRZip;
|
||||
//else if (GetBoolean(features, SharedTorrentLz4Value))
|
||||
// return OutputFormat.TorrentLZ4;
|
||||
//else if (GetBoolean(features, SharedTorrentRarValue))
|
||||
// return OutputFormat.TorrentRar;
|
||||
//else if (GetBoolean(features, SharedTorrentXzValue))
|
||||
// return OutputFormat.TorrentXZ;
|
||||
else if (GetBoolean(features, TorrentZipValue))
|
||||
return OutputFormat.TorrentZip;
|
||||
//else if (GetBoolean(features, SharedTorrentZpaqValue))
|
||||
// return OutputFormat.TorrentZPAQ;
|
||||
//else if (GetBoolean(features, SharedTorrentZstdValue))
|
||||
// return OutputFormat.TorrentZstd;
|
||||
else
|
||||
return OutputFormat.Folder;
|
||||
}
|
||||
|
||||
@@ -42,14 +42,10 @@ namespace SabreTools.Features
|
||||
AddFeature(TorrentGzipFlag);
|
||||
this[TorrentGzipFlag]!.AddFeature(RombaFlag);
|
||||
this[TorrentGzipFlag]![RombaFlag]!.AddFeature(RombaDepthInt32Input);
|
||||
//AddFeature(SharedInputs.TorrentLrzipFlag);
|
||||
//AddFeature(SharedInputs.TorrentLz4Flag);
|
||||
//AddFeature(SharedInputs.TorrentRarFlag);
|
||||
//AddFeature(SharedInputs.TorrentXzFlag);
|
||||
//this[SharedInputs.TorrentXzFlag]!.AddFeature(SharedInputs.RombaFlag);
|
||||
AddFeature(TorrentZipFlag);
|
||||
//AddFeature(SharedInputs.TorrentZpaqFlag);
|
||||
//AddFeature(SharedInputs.TorrentZstdFlag);
|
||||
|
||||
AddFeature(HeaderStringInput);
|
||||
AddInternalSplitFeatures();
|
||||
|
||||
Reference in New Issue
Block a user