From 9f9b54cb897ce1cee6de526044e5fa1ca2a4bf0f Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 5 Oct 2016 20:33:02 -0700 Subject: [PATCH] [ALL] Make ArchiveScanLevel and DupeType flags --- SabreTools.Helper/Data/Enums.cs | 12 ----- SabreTools.Helper/Data/Flags.cs | 69 ++++++++++++++---------- SabreTools.Helper/Objects/Dat/DatFile.cs | 4 +- SabreTools.Helper/Objects/Dat/DatItem.cs | 18 +++---- SabreTools.Helper/Objects/Dat/Disk.cs | 2 +- SabreTools.Helper/Objects/Dat/Rom.cs | 2 +- SabreTools.Helper/README.1ST | 7 +++ SabreTools/Partials/SabreTools_Inits.cs | 3 +- 8 files changed, 63 insertions(+), 54 deletions(-) diff --git a/SabreTools.Helper/Data/Enums.cs b/SabreTools.Helper/Data/Enums.cs index 20691f94..4faa91b1 100644 --- a/SabreTools.Helper/Data/Enums.cs +++ b/SabreTools.Helper/Data/Enums.cs @@ -37,18 +37,6 @@ #region DatItem related - /// - /// Determines which type of duplicate a file is - /// - public enum DupeType - { - None = 0, - InternalHash = 1, - InternalAll = 2, - ExternalHash = 3, - ExternalAll = 4, - } - /// /// Determine what type of file an item is /// diff --git a/SabreTools.Helper/Data/Flags.cs b/SabreTools.Helper/Data/Flags.cs index 0fb52ef5..a2c21896 100644 --- a/SabreTools.Helper/Data/Flags.cs +++ b/SabreTools.Helper/Data/Flags.cs @@ -2,6 +2,33 @@ namespace SabreTools.Helper { + /// + /// Determines the level to scan archives at + /// + [Flags] + public enum ArchiveScanLevel + { + // 7zip + SevenZipExternal = 0x0001, + SevenZipInternal = 0x0002, + SevenZipBoth = SevenZipExternal | SevenZipInternal, + + // GZip + GZipExternal = 0x0010, + GZipInternal = 0x0020, + GZipBoth = GZipExternal | GZipInternal, + + // RAR + RarExternal = 0x0100, + RarInternal = 0x0200, + RarBoth = RarExternal | RarInternal, + + // Zip + ZipExternal = 0x1000, + ZipInternal = 0x2000, + ZipBoth = ZipExternal | ZipInternal, + } + /// /// Determines which diffs should be created /// @@ -19,6 +46,21 @@ namespace SabreTools.Helper ReverseCascade = 0x10, } + /// + /// Determines which type of duplicate a file is + /// + [Flags] + public enum DupeType + { + // Type of match + Hash = 0x01, + All = 0x02, + + // Location of match + Internal = 0x10, + External = 0x20, + } + /// /// Determines the DAT output format /// @@ -92,33 +134,6 @@ namespace SabreTools.Helper Bit2 = 0x0004, } - /// - /// Determines the level to scan archives at - /// - [Flags] - public enum ArchiveScanLevel - { - // 7zip - SevenZipExternal = 0x0001, - SevenZipInternal = 0x0002, - SevenZipBoth = SevenZipExternal | SevenZipInternal, - - // GZip - GZipExternal = 0x0010, - GZipInternal = 0x0020, - GZipBoth = GZipExternal | GZipInternal, - - // RAR - RarExternal = 0x0100, - RarInternal = 0x0200, - RarBoth = RarExternal | RarInternal, - - // Zip - ZipExternal = 0x1000, - ZipInternal = 0x2000, - ZipBoth = ZipExternal | ZipInternal, - } - /// /// Zipfile special status /// diff --git a/SabreTools.Helper/Objects/Dat/DatFile.cs b/SabreTools.Helper/Objects/Dat/DatFile.cs index e418ad05..99f435fd 100644 --- a/SabreTools.Helper/Objects/Dat/DatFile.cs +++ b/SabreTools.Helper/Objects/Dat/DatFile.cs @@ -867,7 +867,7 @@ namespace SabreTools.Helper // No duplicates if ((diff & DiffMode.NoDupes) != 0 || (diff & DiffMode.Individuals) != 0) { - if (rom.Dupe < DupeType.ExternalHash) + if ((rom.Dupe & DupeType.Internal) != 0) { // Individual DATs that are output if ((diff & DiffMode.Individuals) != 0) @@ -907,7 +907,7 @@ namespace SabreTools.Helper // Duplicates only if ((diff & DiffMode.Dupes) != 0) { - if (rom.Dupe >= DupeType.ExternalHash) + if ((rom.Dupe & DupeType.External) != 0) { DatItem newrom = rom; newrom.MachineName += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.SystemID].Split('¬')[0]) + ")"; diff --git a/SabreTools.Helper/Objects/Dat/DatItem.cs b/SabreTools.Helper/Objects/Dat/DatItem.cs index 281abe3a..be5d33fa 100644 --- a/SabreTools.Helper/Objects/Dat/DatItem.cs +++ b/SabreTools.Helper/Objects/Dat/DatItem.cs @@ -248,7 +248,7 @@ namespace SabreTools.Helper /// The DupeType corresponding to the relationship between the two public DupeType GetDuplicateStatus(DatItem lastItem, Logger logger) { - DupeType output = DupeType.None; + DupeType output = 0x00; // If we don't have a duplicate at all, return none if (!this.IsDuplicate(lastItem, logger)) @@ -257,15 +257,15 @@ namespace SabreTools.Helper } // If the duplicate is external already or should be, set it - if (lastItem.Dupe >= DupeType.ExternalHash || lastItem.SystemID != this.SystemID || lastItem.SourceID != this.SourceID) + if ((lastItem.Dupe & DupeType.External) != 0 || lastItem.SystemID != this.SystemID || lastItem.SourceID != this.SourceID) { if (lastItem.MachineName == this.MachineName && lastItem.Name == this.Name) { - output = DupeType.ExternalAll; + output = DupeType.External | DupeType.All; } else { - output = DupeType.ExternalHash; + output = DupeType.External | DupeType.Hash; } } @@ -274,11 +274,11 @@ namespace SabreTools.Helper { if (lastItem.MachineName == this.MachineName && lastItem.Name == this.Name) { - output = DupeType.InternalAll; + output = DupeType.Internal | DupeType.All; } else { - output = DupeType.InternalHash; + output = DupeType.Internal | DupeType.Hash; } } @@ -696,7 +696,7 @@ namespace SabreTools.Helper if (outfiles.Count != 0) { // Check if the rom is a duplicate - DupeType dupetype = DupeType.None; + DupeType dupetype = 0x00; DatItem saveditem = new Rom(); int pos = -1; for (int i = 0; i < outfiles.Count; i++) @@ -707,7 +707,7 @@ namespace SabreTools.Helper dupetype = file.GetDuplicateStatus(lastrom, logger); // If it's a duplicate, skip adding it to the output but add any missing information - if (dupetype != DupeType.None) + if (dupetype != 0x00) { // If we don't have a rom or disk, then just skip adding if (file.Type != ItemType.Rom && file.Type != ItemType.Disk) @@ -767,7 +767,7 @@ namespace SabreTools.Helper } // If no duplicate is found, add it to the list - if (dupetype == DupeType.None) + if (dupetype == 0x00) { outfiles.Add(file); } diff --git a/SabreTools.Helper/Objects/Dat/Disk.cs b/SabreTools.Helper/Objects/Dat/Disk.cs index 2a6c496d..e423e361 100644 --- a/SabreTools.Helper/Objects/Dat/Disk.cs +++ b/SabreTools.Helper/Objects/Dat/Disk.cs @@ -44,7 +44,7 @@ namespace SabreTools.Helper { _name = ""; _itemType = ItemType.Disk; - _dupeType = DupeType.None; + _dupeType = 0x00; _itemStatus = ItemStatus.None; } diff --git a/SabreTools.Helper/Objects/Dat/Rom.cs b/SabreTools.Helper/Objects/Dat/Rom.cs index 5ffef5ba..51d33031 100644 --- a/SabreTools.Helper/Objects/Dat/Rom.cs +++ b/SabreTools.Helper/Objects/Dat/Rom.cs @@ -43,7 +43,7 @@ namespace SabreTools.Helper { _name = ""; _itemType = ItemType.Rom; - _dupeType = DupeType.None; + _dupeType = 0x00; _itemStatus = ItemStatus.None; _date = ""; } diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST index 6c7874d0..1f6b4984 100644 --- a/SabreTools.Helper/README.1ST +++ b/SabreTools.Helper/README.1ST @@ -718,6 +718,13 @@ Options: the present, but it is mostly meant for Romba compatibility at the present. If a DAT is supplied, then files NOT matching the DAT will be written out only. + -r, --romba Enable Romba depot directory output + As an extension of the parent flag, this outputs the TGZ files into directories + based on the structure used by Romba. This uses nested folders using the first + 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. + -tzip Enable TorrentZip output Instead of outputting the files to standard ZIP archives, files will be rebuilt to TorrentZip (TZ) files. This format is based on the ZIP archive format, but with diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index be7318f9..1c381b28 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -1,5 +1,4 @@ -using Mono.Data.Sqlite; -using SabreTools.Helper; +using SabreTools.Helper; using System; using System.Collections.Generic; using System.IO;