[ALL] Make ArchiveScanLevel and DupeType flags

This commit is contained in:
Matt Nadareski
2016-10-05 20:33:02 -07:00
parent 9d42cdf805
commit 9f9b54cb89
8 changed files with 63 additions and 54 deletions

View File

@@ -37,18 +37,6 @@
#region DatItem related #region DatItem related
/// <summary>
/// Determines which type of duplicate a file is
/// </summary>
public enum DupeType
{
None = 0,
InternalHash = 1,
InternalAll = 2,
ExternalHash = 3,
ExternalAll = 4,
}
/// <summary> /// <summary>
/// Determine what type of file an item is /// Determine what type of file an item is
/// </summary> /// </summary>

View File

@@ -2,6 +2,33 @@
namespace SabreTools.Helper namespace SabreTools.Helper
{ {
/// <summary>
/// Determines the level to scan archives at
/// </summary>
[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,
}
/// <summary> /// <summary>
/// Determines which diffs should be created /// Determines which diffs should be created
/// </summary> /// </summary>
@@ -19,6 +46,21 @@ namespace SabreTools.Helper
ReverseCascade = 0x10, ReverseCascade = 0x10,
} }
/// <summary>
/// Determines which type of duplicate a file is
/// </summary>
[Flags]
public enum DupeType
{
// Type of match
Hash = 0x01,
All = 0x02,
// Location of match
Internal = 0x10,
External = 0x20,
}
/// <summary> /// <summary>
/// Determines the DAT output format /// Determines the DAT output format
/// </summary> /// </summary>
@@ -92,33 +134,6 @@ namespace SabreTools.Helper
Bit2 = 0x0004, Bit2 = 0x0004,
} }
/// <summary>
/// Determines the level to scan archives at
/// </summary>
[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,
}
/// <summary> /// <summary>
/// Zipfile special status /// Zipfile special status
/// </summary> /// </summary>

View File

@@ -867,7 +867,7 @@ namespace SabreTools.Helper
// No duplicates // No duplicates
if ((diff & DiffMode.NoDupes) != 0 || (diff & DiffMode.Individuals) != 0) 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 // Individual DATs that are output
if ((diff & DiffMode.Individuals) != 0) if ((diff & DiffMode.Individuals) != 0)
@@ -907,7 +907,7 @@ namespace SabreTools.Helper
// Duplicates only // Duplicates only
if ((diff & DiffMode.Dupes) != 0) if ((diff & DiffMode.Dupes) != 0)
{ {
if (rom.Dupe >= DupeType.ExternalHash) if ((rom.Dupe & DupeType.External) != 0)
{ {
DatItem newrom = rom; DatItem newrom = rom;
newrom.MachineName += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.SystemID].Split('¬')[0]) + ")"; newrom.MachineName += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.SystemID].Split('¬')[0]) + ")";

View File

@@ -248,7 +248,7 @@ namespace SabreTools.Helper
/// <returns>The DupeType corresponding to the relationship between the two</returns> /// <returns>The DupeType corresponding to the relationship between the two</returns>
public DupeType GetDuplicateStatus(DatItem lastItem, Logger logger) 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 we don't have a duplicate at all, return none
if (!this.IsDuplicate(lastItem, logger)) if (!this.IsDuplicate(lastItem, logger))
@@ -257,15 +257,15 @@ namespace SabreTools.Helper
} }
// If the duplicate is external already or should be, set it // 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) if (lastItem.MachineName == this.MachineName && lastItem.Name == this.Name)
{ {
output = DupeType.ExternalAll; output = DupeType.External | DupeType.All;
} }
else 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) if (lastItem.MachineName == this.MachineName && lastItem.Name == this.Name)
{ {
output = DupeType.InternalAll; output = DupeType.Internal | DupeType.All;
} }
else else
{ {
output = DupeType.InternalHash; output = DupeType.Internal | DupeType.Hash;
} }
} }
@@ -696,7 +696,7 @@ namespace SabreTools.Helper
if (outfiles.Count != 0) if (outfiles.Count != 0)
{ {
// Check if the rom is a duplicate // Check if the rom is a duplicate
DupeType dupetype = DupeType.None; DupeType dupetype = 0x00;
DatItem saveditem = new Rom(); DatItem saveditem = new Rom();
int pos = -1; int pos = -1;
for (int i = 0; i < outfiles.Count; i++) for (int i = 0; i < outfiles.Count; i++)
@@ -707,7 +707,7 @@ namespace SabreTools.Helper
dupetype = file.GetDuplicateStatus(lastrom, logger); dupetype = file.GetDuplicateStatus(lastrom, logger);
// If it's a duplicate, skip adding it to the output but add any missing information // 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 we don't have a rom or disk, then just skip adding
if (file.Type != ItemType.Rom && file.Type != ItemType.Disk) 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 no duplicate is found, add it to the list
if (dupetype == DupeType.None) if (dupetype == 0x00)
{ {
outfiles.Add(file); outfiles.Add(file);
} }

View File

@@ -44,7 +44,7 @@ namespace SabreTools.Helper
{ {
_name = ""; _name = "";
_itemType = ItemType.Disk; _itemType = ItemType.Disk;
_dupeType = DupeType.None; _dupeType = 0x00;
_itemStatus = ItemStatus.None; _itemStatus = ItemStatus.None;
} }

View File

@@ -43,7 +43,7 @@ namespace SabreTools.Helper
{ {
_name = ""; _name = "";
_itemType = ItemType.Rom; _itemType = ItemType.Rom;
_dupeType = DupeType.None; _dupeType = 0x00;
_itemStatus = ItemStatus.None; _itemStatus = ItemStatus.None;
_date = ""; _date = "";
} }

View File

@@ -718,6 +718,13 @@ Options:
the present, but it is mostly meant for Romba compatibility at the present. If a DAT 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. 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 -tzip Enable TorrentZip output
Instead of outputting the files to standard ZIP archives, files will be rebuilt to 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 TorrentZip (TZ) files. This format is based on the ZIP archive format, but with

View File

@@ -1,5 +1,4 @@
using Mono.Data.Sqlite; using SabreTools.Helper;
using SabreTools.Helper;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;