diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 224ac556..49c7c41b 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -3942,7 +3942,7 @@ namespace SabreTools.Library.DatFiles case OutputFormat.TorrentGzip: format = "TorrentGZ"; break; - case OutputFormat.TorrentLrzip: + case OutputFormat.TorrentLRZip: format = "TorrentLRZ"; break; case OutputFormat.TorrentRar: @@ -4120,7 +4120,7 @@ namespace SabreTools.Library.DatFiles case OutputFormat.TorrentGzip: format = "TorrentGZ"; break; - case OutputFormat.TorrentLrzip: + case OutputFormat.TorrentLRZip: format = "TorrentLRZ"; break; case OutputFormat.TorrentRar: diff --git a/SabreTools.Library/Data/Enums.cs b/SabreTools.Library/Data/Enums.cs index 22d6db62..84af9b3a 100644 --- a/SabreTools.Library/Data/Enums.cs +++ b/SabreTools.Library/Data/Enums.cs @@ -100,11 +100,14 @@ TorrentGzip = 2, TapeArchive = 5, - // Currently unimplemented + // Currently unimplemented fully Torrent7Zip = 3, TorrentRar = 4, TorrentXZ = 6, - TorrentLrzip = 7, + TorrentLRZip = 7, + TorrentLZ4 = 8, + TorrentZstd = 9, + TorrentZPAQ = 10, } /// diff --git a/SabreTools.Library/FileTypes/LRZArchive.cs b/SabreTools.Library/FileTypes/LRZipArchive.cs similarity index 94% rename from SabreTools.Library/FileTypes/LRZArchive.cs rename to SabreTools.Library/FileTypes/LRZipArchive.cs index 06fb54d7..782dbb8e 100644 --- a/SabreTools.Library/FileTypes/LRZArchive.cs +++ b/SabreTools.Library/FileTypes/LRZipArchive.cs @@ -16,25 +16,24 @@ namespace SabreTools.Library.FileTypes /// /// Represents a TorrentLRZip archive for reading and writing /// - /// TODO: LRZIP: https://github.com/ckolivas/lrzip - public class LRZArchive : BaseArchive + /// TODO: Implement from source at https://github.com/ckolivas/lrzip + public class LRZipArchive : BaseArchive { #region Constructors /// - /// Create a new TorrentGZipArchive with no base file + /// Create a new LRZipArchive with no base file /// - public LRZArchive() + public LRZipArchive() : base() { } /// - /// Create a new TorrentGZipArchive from the given file + /// Create a new LRZipArchive from the given file /// /// Name of the file to use as an archive - /// True for opening file as read, false for opening file as write - public LRZArchive(string filename) + public LRZipArchive(string filename) : base(filename) { //_archiveType = ArchiveType.LRZip; diff --git a/SabreTools.Library/FileTypes/LZ4Archive.cs b/SabreTools.Library/FileTypes/LZ4Archive.cs new file mode 100644 index 00000000..83d6baf8 --- /dev/null +++ b/SabreTools.Library/FileTypes/LZ4Archive.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; + +using SabreTools.Library.Data; +using SabreTools.Library.Items; + +#if MONO +using System.IO; +#else +using MemoryStream = System.IO.MemoryStream; +using Stream = System.IO.Stream; +#endif + +namespace SabreTools.Library.FileTypes +{ + /// + /// Represents a TorrentLRZip archive for reading and writing + /// + /// TODO: Implement from source at https://github.com/lz4/lz4 + public class LZ4Archive : BaseArchive + { + #region Constructors + + /// + /// Create a new LZ4Archive with no base file + /// + public LZ4Archive() + : base() + { + } + + /// + /// Create a new LZ4Archive from the given file + /// + /// Name of the file to use as an archive + public LZ4Archive(string filename) + : base(filename) + { + //_archiveType = ArchiveType.LRZip; + } + + #endregion + + #region Extraction + + /// + /// Attempt to extract a file as an archive + /// + /// Output directory for archive extraction + /// True if the extraction was a success, false otherwise + public override bool ExtractAll(string outDir) + { + throw new NotImplementedException(); + } + + /// + /// Attempt to extract a file from an archive + /// + /// Name of the entry to be extracted + /// Output directory for archive extraction + /// Name of the extracted file, null on error + public override string ExtractEntry(string entryName, string outDir) + { + throw new NotImplementedException(); + } + + /// + /// Attempt to extract a stream from an archive + /// + /// Name of the entry to be extracted + /// Output representing the entry name that was found + /// MemoryStream representing the entry, null on error + public override (MemoryStream, string) ExtractEntryStream(string entryName) + { + throw new NotImplementedException(); + } + + #endregion + + #region Information + + /// + /// Generate a list of DatItem objects from the header values in an archive + /// + /// Hash representing the hashes that should be skipped + /// True if entry dates should be included, false otherwise (default) + /// List of DatItem objects representing the found data + /// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually + public override List GetArchiveFileInfo(Hash omitFromScan = Hash.DeepHashes, bool date = false) + { + throw new NotImplementedException(); + } + + /// + /// Generate a list of empty folders in an archive + /// + /// Input file to get data from + /// List of empty folders in the archive + public override List GetEmptyFolders() + { + throw new NotImplementedException(); + } + + /// + /// Check whether the input file is a standardized format + /// + public override bool IsTorrent() + { + throw new NotImplementedException(); + } + + #endregion + + #region Writing + + /// + /// Write an input file to a torrent LZ4 file + /// + /// Input filename to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the write was a success, false otherwise + /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code. + public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + /// + /// Write an input stream to a torrent LZ4 file + /// + /// Input stream to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the write was a success, false otherwise + /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code. + public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + /// + /// Write a set of input files to a torrent LZ4 archive (assuming the same output archive name) + /// + /// Input files to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the archive was written properly, false otherwise + public override bool Write(List inputFiles, string outDir, List roms, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + #endregion + } +} diff --git a/SabreTools.Library/FileTypes/ZPAQArchive.cs b/SabreTools.Library/FileTypes/ZPAQArchive.cs new file mode 100644 index 00000000..9a19ccc7 --- /dev/null +++ b/SabreTools.Library/FileTypes/ZPAQArchive.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; + +using SabreTools.Library.Data; +using SabreTools.Library.Items; + +#if MONO +using System.IO; +#else +using MemoryStream = System.IO.MemoryStream; +using Stream = System.IO.Stream; +#endif + +namespace SabreTools.Library.FileTypes +{ + /// + /// Represents a ZPAQArchive archive for reading and writing + /// + /// TODO: Implement from source at https://github.com/zpaq/zpaq - In progress as external DLL + public class ZPAQArchive : BaseArchive + { + #region Constructors + + /// + /// Create a new ZPAQArchive with no base file + /// + public ZPAQArchive() + : base() + { + } + + /// + /// Create a new ZPAQArchive from the given file + /// + /// Name of the file to use as an archive + public ZPAQArchive(string filename) + : base(filename) + { + //_archiveType = ArchiveType.LRZip; + } + + #endregion + + #region Extraction + + /// + /// Attempt to extract a file as an archive + /// + /// Output directory for archive extraction + /// True if the extraction was a success, false otherwise + public override bool ExtractAll(string outDir) + { + throw new NotImplementedException(); + } + + /// + /// Attempt to extract a file from an archive + /// + /// Name of the entry to be extracted + /// Output directory for archive extraction + /// Name of the extracted file, null on error + public override string ExtractEntry(string entryName, string outDir) + { + throw new NotImplementedException(); + } + + /// + /// Attempt to extract a stream from an archive + /// + /// Name of the entry to be extracted + /// Output representing the entry name that was found + /// MemoryStream representing the entry, null on error + public override (MemoryStream, string) ExtractEntryStream(string entryName) + { + throw new NotImplementedException(); + } + + #endregion + + #region Information + + /// + /// Generate a list of DatItem objects from the header values in an archive + /// + /// Hash representing the hashes that should be skipped + /// True if entry dates should be included, false otherwise (default) + /// List of DatItem objects representing the found data + /// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually + public override List GetArchiveFileInfo(Hash omitFromScan = Hash.DeepHashes, bool date = false) + { + throw new NotImplementedException(); + } + + /// + /// Generate a list of empty folders in an archive + /// + /// Input file to get data from + /// List of empty folders in the archive + public override List GetEmptyFolders() + { + throw new NotImplementedException(); + } + + /// + /// Check whether the input file is a standardized format + /// + public override bool IsTorrent() + { + throw new NotImplementedException(); + } + + #endregion + + #region Writing + + /// + /// Write an input file to a torrent ZPAQ file + /// + /// Input filename to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the write was a success, false otherwise + /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code. + public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + /// + /// Write an input stream to a torrent ZPAQ file + /// + /// Input stream to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the write was a success, false otherwise + /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code. + public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + /// + /// Write a set of input files to a torrent ZPAQ archive (assuming the same output archive name) + /// + /// Input files to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the archive was written properly, false otherwise + public override bool Write(List inputFiles, string outDir, List roms, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + #endregion + } +} diff --git a/SabreTools.Library/FileTypes/ZstdArchive.cs b/SabreTools.Library/FileTypes/ZstdArchive.cs new file mode 100644 index 00000000..bcafc860 --- /dev/null +++ b/SabreTools.Library/FileTypes/ZstdArchive.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; + +using SabreTools.Library.Data; +using SabreTools.Library.Items; + +#if MONO +using System.IO; +#else +using MemoryStream = System.IO.MemoryStream; +using Stream = System.IO.Stream; +#endif + +namespace SabreTools.Library.FileTypes +{ + /// + /// Represents a ZstdArchive archive for reading and writing + /// + /// TODO: Implement from source at https://github.com/skbkontur/ZstdNet + public class ZstdArchive : BaseArchive + { + #region Constructors + + /// + /// Create a new ZstdArchive with no base file + /// + public ZstdArchive() + : base() + { + } + + /// + /// Create a new ZstdArchive from the given file + /// + /// Name of the file to use as an archive + public ZstdArchive(string filename) + : base(filename) + { + //_archiveType = ArchiveType.LRZip; + } + + #endregion + + #region Extraction + + /// + /// Attempt to extract a file as an archive + /// + /// Output directory for archive extraction + /// True if the extraction was a success, false otherwise + public override bool ExtractAll(string outDir) + { + throw new NotImplementedException(); + } + + /// + /// Attempt to extract a file from an archive + /// + /// Name of the entry to be extracted + /// Output directory for archive extraction + /// Name of the extracted file, null on error + public override string ExtractEntry(string entryName, string outDir) + { + throw new NotImplementedException(); + } + + /// + /// Attempt to extract a stream from an archive + /// + /// Name of the entry to be extracted + /// Output representing the entry name that was found + /// MemoryStream representing the entry, null on error + public override (MemoryStream, string) ExtractEntryStream(string entryName) + { + throw new NotImplementedException(); + } + + #endregion + + #region Information + + /// + /// Generate a list of DatItem objects from the header values in an archive + /// + /// Hash representing the hashes that should be skipped + /// True if entry dates should be included, false otherwise (default) + /// List of DatItem objects representing the found data + /// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually + public override List GetArchiveFileInfo(Hash omitFromScan = Hash.DeepHashes, bool date = false) + { + throw new NotImplementedException(); + } + + /// + /// Generate a list of empty folders in an archive + /// + /// Input file to get data from + /// List of empty folders in the archive + public override List GetEmptyFolders() + { + throw new NotImplementedException(); + } + + /// + /// Check whether the input file is a standardized format + /// + public override bool IsTorrent() + { + throw new NotImplementedException(); + } + + #endregion + + #region Writing + + /// + /// Write an input file to a torrent Zstd file + /// + /// Input filename to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the write was a success, false otherwise + /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code. + public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + /// + /// Write an input stream to a torrent Zstd file + /// + /// Input stream to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the write was a success, false otherwise + /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code. + public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + /// + /// Write a set of input files to a torrent Zstd archive (assuming the same output archive name) + /// + /// Input files to be moved + /// Output directory to build to + /// DatItem representing the new information + /// True if the date from the DAT should be used if available, false otherwise (default) + /// True if files should be output in Romba depot folders, false otherwise + /// True if the archive was written properly, false otherwise + public override bool Write(List inputFiles, string outDir, List roms, bool date = false, bool romba = false) + { + throw new NotImplementedException(); + } + + #endregion + } +} diff --git a/SabreTools.Library/README.1ST b/SabreTools.Library/README.1ST index d62b9894..eb732757 100644 --- a/SabreTools.Library/README.1ST +++ b/SabreTools.Library/README.1ST @@ -549,6 +549,13 @@ Options: but with custom header information. This is currently unused by any major application. + -tlz4 Enable Torrent LZ4 output [UNIMPLEMENTED] + Instead of ouputting the files to folder, files will be rebuilt to + Torrent LZ4 (TLZ4) files. This format is based on the LZ4 file + format as defined at https://github.com/lz4/lz4 but with custom + header information. This is currently unused by any major + application. + -trar Enable Torrent RAR output [UNIMPLEMENTED] Instead of outputting files to folder, files will be rebuilt to Torrent RAR (TRAR) files. This format is based on the RAR propietary @@ -568,6 +575,20 @@ Options: format, but with custom header information. This is primarily used by external tool RomVault (http://www.romvault.com/) and is already widely used. + + -tzpaq Enable Torrent ZPAQ output [UNIMPLEMENTED] + Instead of ouputting the files to folder, files will be rebuilt to + Torrent ZPAQ (TZPAQ) files. This format is based on the ZPAQ file + format as defined at https://github.com/zpaq/zpaq but with custom + header information. This is currently unused by any major + application. + + -tzstd Enable Torrent Zstd output [UNIMPLEMENTED] + Instead of ouputting the files to folder, files will be rebuilt to + Torrent Zstd (TZstd) files. This format is based on the Zstd file + format as defined at https://github.com/skbkontur/ZstdNet but with + custom header information. This is currently unused by any major + application. -h=, --header= Remove headers from hash calculations If this is set, then all files that have copier headers that are @@ -697,6 +718,13 @@ Options: but with custom header information. This is currently unused by any major application. + -tlz4 Enable Torrent LZ4 output [UNIMPLEMENTED] + Instead of ouputting the files to folder, files will be rebuilt to + Torrent LZ4 (TLZ4) files. This format is based on the LZ4 file + format as defined at https://github.com/lz4/lz4 but with custom + header information. This is currently unused by any major + application. + -trar Enable Torrent RAR output [UNIMPLEMENTED] Instead of outputting files to folder, files will be rebuilt to Torrent RAR (TRAR) files. This format is based on the RAR propietary @@ -717,6 +745,20 @@ Options: by external tool RomVault (http://www.romvault.com/) and is already widely used. + -tzpaq Enable Torrent ZPAQ output [UNIMPLEMENTED] + Instead of ouputting the files to folder, files will be rebuilt to + Torrent ZPAQ (TZPAQ) files. This format is based on the ZPAQ file + format as defined at https://github.com/zpaq/zpaq but with custom + header information. This is currently unused by any major + application. + + -tzstd Enable Torrent Zstd output [UNIMPLEMENTED] + Instead of ouputting the files to folder, files will be rebuilt to + Torrent Zstd (TZstd) files. This format is based on the Zstd file + format as defined at https://github.com/skbkontur/ZstdNet but with + custom header information. This is currently unused by any major + application. + -h=, --header= Remove headers from hash calculations If this is set, then all files that have copier headers that are detected will have them removed from the hash calculation. This will diff --git a/SabreTools.Library/SabreTools.Library.csproj b/SabreTools.Library/SabreTools.Library.csproj index ca61f9e6..6a15077e 100644 --- a/SabreTools.Library/SabreTools.Library.csproj +++ b/SabreTools.Library/SabreTools.Library.csproj @@ -153,12 +153,15 @@ - + + + + diff --git a/SabreTools.Library/Tools/ArchiveTools.cs b/SabreTools.Library/Tools/ArchiveTools.cs index db6726c9..535d3d4c 100644 --- a/SabreTools.Library/Tools/ArchiveTools.cs +++ b/SabreTools.Library/Tools/ArchiveTools.cs @@ -1,9 +1,7 @@ using System; -using System.Text.RegularExpressions; using SabreTools.Library.Data; using SabreTools.Library.FileTypes; -using SabreTools.Library.Items; #if MONO using System.IO; @@ -21,15 +19,9 @@ namespace SabreTools.Library.Tools /// /// Tools for working with archives /// - /// - /// TODO: Full archive support for: RAR, LRZip, ZPAQ?, Zstd?, LZ4? - /// ZPAQ: https://github.com/zpaq/zpaq - In progress as external DLL - /// Zstd: https://github.com/skbkontur/ZstdNet - /// LZ4: https://github.com/lz4/lz4 - /// public static class ArchiveTools { - #region Factory + #region Factories /// /// Create an archive of the specified type, if possible @@ -114,8 +106,8 @@ namespace SabreTools.Library.Tools return new SevenZipArchive(); case OutputFormat.TorrentGzip: return new GZipArchive(); - case OutputFormat.TorrentLrzip: - return new LRZArchive(); + case OutputFormat.TorrentLRZip: + return new LRZipArchive(); case OutputFormat.TorrentRar: return new RarArchive(); case OutputFormat.TorrentXZ: diff --git a/SabreTools/SabreTools.Help.cs b/SabreTools/SabreTools.Help.cs index 565b3ba7..3a870ef6 100644 --- a/SabreTools/SabreTools.Help.cs +++ b/SabreTools/SabreTools.Help.cs @@ -462,6 +462,13 @@ namespace SabreTools null)); */ /* + sort.AddFeature("tlz4", new Feature( + new List() { "-tlz4", "--tlz4" }, + "Enable TorrentLZ4 output", + FeatureType.Flag, + null)); + */ + /* sort.AddFeature("trar", new Feature( new List() { "-trar", "--trar" }, "Enable TorrentRAR output", @@ -480,6 +487,20 @@ namespace SabreTools "Enable TorrentZip output", FeatureType.Flag, null)); + /* + sort.AddFeature("tzpaq", new Feature( + new List() { "-tzpaq", "--tzpaq" }, + "Enable TorrentZPAQ output", + FeatureType.Flag, + null)); + */ + /* + sort.AddFeature("tzstd", new Feature( + new List() { "-tzstd", "--tzstd" }, + "Enable TorrentZstd output", + FeatureType.Flag, + null)); + */ sort.AddFeature("header", new Feature( new List() { "-h", "--header" }, "Set a header skipper to use, blank means all", @@ -600,6 +621,13 @@ namespace SabreTools null)); */ /* + sortDepot.AddFeature("tlz4", new Feature( + new List() { "-tlz4", "--tlz4" }, + "Enable TorrentLZ4 output", + FeatureType.Flag, + null)); + */ + /* sortDepot.AddFeature("trar", new Feature( new List() { "-trar", "--trar" }, "Enable TorrentRAR output", @@ -618,6 +646,20 @@ namespace SabreTools "Enable TorrentZip output", FeatureType.Flag, null)); + /* + sortDepot.AddFeature("tzpaq", new Feature( + new List() { "-tzpaq", "--tzpaq" }, + "Enable TorrentZPAQ output", + FeatureType.Flag, + null)); + */ + /* + sortDepot.AddFeature("tzstd", new Feature( + new List() { "-tzstd", "--tzstd" }, + "Enable TorrentZstd output", + FeatureType.Flag, + null)); + */ sortDepot.AddFeature("header", new Feature( new List() { "-h", "--header" }, "Set a header skipper to use, blank means all", diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 0f8b9860..da5eeb5b 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -615,7 +615,11 @@ namespace SabreTools break; case "-tlrz": case "--tlrz": - outputFormat = OutputFormat.TorrentLrzip; + outputFormat = OutputFormat.TorrentLRZip; + break; + case "-lz4": + case "--tlz4": + outputFormat = OutputFormat.TorrentLZ4; break; case "-trar": case "--trar": @@ -637,6 +641,14 @@ namespace SabreTools case "--tzip": outputFormat = OutputFormat.TorrentZip; break; + case "-tzpaq": + case "--tzpaq": + outputFormat = OutputFormat.TorrentZPAQ; + break; + case "-tzstd": + case "--tzstd": + outputFormat = OutputFormat.TorrentZstd; + break; case "-upd": case "--update-dat": updateDat = true;