[ALL] Move to new folders to reflect names

This commit is contained in:
Matt Nadareski
2016-06-12 20:20:50 -07:00
parent 56b35bad6b
commit 4c7942e46e
61 changed files with 13 additions and 13 deletions

View File

@@ -0,0 +1,254 @@
using System;
using System.Diagnostics;
namespace SabreTools.Helper
{
public class Build
{
/// <summary>
/// Returns true if running in a Mono environment
/// </summary>
public static bool MonoEnvironment
{
get { return (Type.GetType("Mono.Runtime") != null); }
}
/// <summary>
/// Readies the console and outputs the header
/// </summary>
/// <param name="name">The name to be displayed as the program</param>
/// <remarks>Adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string</remarks>
public static void Start(string name)
{
// Dynamically create the header string
string border = "+-----------------------------------------------------------------------------+";
string mid = name + " " + Constants.Version;
mid = "|" + mid.PadLeft(((77 - mid.Length) / 2) + mid.Length).PadRight(77) + "|";
// If we're outputting to console, do fancy things
if (!Console.IsOutputRedirected)
{
// Set the console to ready state
ConsoleColor formertext = ConsoleColor.White;
ConsoleColor formerback = ConsoleColor.Black;
if (!MonoEnvironment)
{
Console.SetBufferSize(Console.BufferWidth, 999);
formertext = Console.ForegroundColor;
formerback = Console.BackgroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Blue;
}
Console.Title = "SabreTools-" + name + " " + Constants.Version;
// Output the header
Console.WriteLine(border);
Console.WriteLine(mid);
Console.WriteLine(border);
Console.WriteLine();
// Return the console to the original text and background colors
if (!MonoEnvironment)
{
Console.ForegroundColor = formertext;
Console.BackgroundColor = formerback;
}
}
}
/// <summary>
/// Show the help dialog for a given class
/// </summary>
public static void Help()
{
//http://stackoverflow.com/questions/14849367/how-to-determine-calling-method-and-class-name
StackTrace st = new StackTrace();
string className = st.GetFrame(1).GetMethod().ReflectedType.Name;
switch (className)
{
case "DATabase":
Console.Write(@"
DATabase - Import and Generate DAT files
-----------------------------------------
Usage: DATabase [option] [filename|dirname] ...
Options:
-?, -h, --help Show this help
-a, --add Add a new system or source to the database
-manu= Manufacturer name (system only)
-system= System name (system only)
-source= Source name (source only)
-url= URL (source only)
-d, --dfd Enable Dir2DAT mode
-nm, --noMD5 Don't include MD5 in output
-ns, --noSHA1 Don't include SHA1 in output
-b, --bare Don't include date in file name
-u, --unzip Force unzipping in created DAT
-f, --files Treat archives as files
-o, --old Output DAT in CMP format instead of XML
-gz, --gz-files Allow reading of GZIP files as archives
-ro, --romba Read files from a Romba input
-f=, --filename= Set the external name of the DAT
-n=, --name= Set the internal name of the DAT
-d=, --desc= Set the description of the DAT
-c=, --cat= Set the category of the DAT
-v=, --version= Set the version of the DAT
-au=, --author= Set the author of the DAT
-sd, --superdat Enable SuperDAT creation
-t=, --temp= Set the temporary directory to use
-es, --ext-split Split a DAT by two file extensions
-exta= First set of extensions (comma-separated)
-extb= Second set of extensions (comma-separated)
-out= Output directory
-g, --generate Start tool in generate mode
-system= System ID to generate from
-nr, --no-rename Don't auto-rename games
-o, --old Output DAT in CMP format instead of XML
-ga, --generate-all Start tool in generate all mode
-nr, --no-rename Don't auto-rename games
-o, --old Output DAT in CMP format instead of XML
-hs, --hash-split Split a DAT or folder by best-available hashes
-out= Output directory
-i, --import Start tool in import mode
-ig, --ignore Don't prompt for new sources
-lso, --list-sources List all sources (id <= name)
-lsy, --list-systems List all systems (id <= name)
-m, --merge Merge one or more DATs
-di, --diff Output all diffdats (merge flag not required)
-c, --cascade Enable cascaded diffing
-ip, --inplace Enable inplace, cascaded diffing
-dd, --dedup Enable deduping in the created DAT
-b, --bare Don't include date in file name
-u, --unzip Force unzipping in created DAT
-o, --old Output DAT in CMP format instead of XML
-clean Clean game names according to WoD standards
-out= Output directory (overridden by --inplace)
-sd, --superdat Enable SuperDAT creation
-n=, --name= Set the internal name of the DAT
-de=, --desc= Set the filename and description of the DAT
-ca=, --category= Set the category of the DAT
-v=, --version= Set the version of the DAT
-au=, --author= Set the author of the DAT
-rm, --remove Remove a system or source from the database
-system= System ID
-source= Source ID
-st, --stats Get statistics on all input DATs
-si, --single Show individual statistics
-tm, --trim-merge Consolidate DAT into a single game and trim entries
-rd=, --root-dir= Set the root directory for trimming calculation
-nr, --no-rename Keep game names instead of using '!'
-df, --disable-force Disable forceunzipping
-ud, --update Update a DAT file
-oc, --output-cmp Output in CMP format
-om, --output-miss Output in Missfile format
-r, --roms Output roms to miss instead of sets
-gp, --game-prefix Add game name as a prefix to each item
-pre=, --prefix= Set prefix for all lines
-post=, --postfix= Set postfix for all lines
-q, --quotes Put double-quotes around each item
-ae=, --add-ext= Add an extension to each item
-re=, --rep-ext= Replace all extensions with specified
-ro, --romba Output in Romba format (requires SHA-1)
-tsv, --tsv Output in Tab-Separated Value format
-or, --output-rc Output in RomCenter format
-os, --output-sd Output in SabreDAT format
-ox, --output-xml Output in Logiqx XML format
-f=, --filename= Set a new filename
-n=, --name= Set a new internal name
-de=, --desc= Set a new description
-ca=, --category= Set a new category
-v=, --version= Set a new version
-da=, --date= Set a new date
-au=, --author= Set a new author
-em=, --email= Set a new email
-hp=, --homepage= Set a new homepage
-u=, --url= Set a new URL
-co=, --comment= Set a new comment
-h=, --header= Set a new header skipper
-sd=, --superdat Set SuperDAT type
-fm=, --forcemerge= Set force merging
Supported values are:
None, Split, Full
-fn=, --forcend= Set force nodump
Supported values are:
None, Obsolete, Required, Ignore
-fp=, --forcepack= Set force packing
Supported values are:
None, Zip, Unzip
-clean Clean game names according to WoD standards
-dd, --dedup Enable deduping in the created DAT
-gn=, --game-name= Filter by game name
-rn=, --rom-name= Filter by rom name
-rt=, --rom-type= Filter by rom type
-sgt=, --greater= Filter by size >=
-slt=, --less= Filter by size <=
-seq=, --equal= Filter by size ==
-crc=, --crc= Filter by CRC hash
-md5=, --md5= Filter by MD5 hash
-sha1=, --sha1= Filter by SHA-1 hash
-nd, --nodump Include only match nodump roms
-nnd, --not-nodump Exclude all nodump roms
-out= Output directory
Filenames and directories can't start with a reserved string
unless prefixed by 'input='
Filter parameters game name, rom name, CRC, MD5, SHA-1 can
do partial matches using asterisks as follows (case insensitive):
*00 means ends with '00'
00* means starts with '00'
*00* means contains '00'
00 means exactly equals '00'");
break;
case "Headerer":
Console.WriteLine(@"Headerer - Remove and restore rom headers
-----------------------------------------
Usage: Headerer [option] [filename|dirname]
Options:
-e Detect and remove mode
-r Restore header to file based on SHA-1");
break;
case "OfflineMerge":
Console.WriteLine(@"OfflineMerge - Update DATS for offline arrays
-----------------------------------------
Usage: OfflineMerge [options] [inputs]
Options:
-h, -?, --help Show this help dialog
-f, --fake Replace all hashes and sizes by the default
Inputs:
-com= Complete current DAT
-fix= Complete current Missing
-new= New Complete DAT
This program will output the following DATs:
(a) Net New - (NewComplete)-(Complete)
(b) Unneeded - (Complete)-(NewComplete)
(c) New Missing - (Net New)+(Missing-(Unneeded))
(d) Have - (NewComplete)-(New Missing)
OR (Complete or NewComplete)-(Missing) if one is missing");
break;
default:
Console.Write("This is the default help output");
break;
}
}
public static void Credits()
{
Console.WriteLine(@"-----------------------------------------
Credits
-----------------------------------------
Programmer / Lead: Matt Nadareski (darksabre76)
Additional code: emuLOAD, @tractivo
Testing: emuLOAD, @tractivo, Kludge, Obiwantje, edc
Suggestions: edc, AcidX, Amiga12, EliUmniCk
Based on work by: The Wizard of DATz");
}
}
}

View File

@@ -0,0 +1,67 @@
using System;
namespace SabreTools.Helper
{
public class Constants
{
/// <summary>
/// The current toolset version to be used by all child applications
/// </summary>
public static string Version = "v0.8.3";
// 0-byte file constants
public static long SizeZero = 0;
public static string CRCZero = "00000000";
public static string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
public static string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
// Regex File Name Patterns
public static string DefaultPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.dat$";
public static string DefaultSpecialPattern = @"^(.+?) - (.+?) \((.*) (.*)\)\.xml$";
public static string GoodPattern = @"^(Good.*?)_.*\.dat";
public static string GoodXmlPattern = @"^(Good.*?)_.*\.xml";
public static string MamePattern = @"^(.*)\.xml$";
public static string MaybeIntroPattern = @"(.*?) \[T-En\].*\((\d{8})\)\.dat$";
public static string NoIntroPattern = @"^(.*?) \((\d{8}-\d{6})_CM\).*\.dat$";
public static string NoIntroNumberedPattern = @"(.*? - .*?) \(\d.*?_CM\).*.dat";
public static string NoIntroSpecialPattern = @"(.*? - .*?) \((\d{8})\).*\.dat";
public static string NonGoodPattern = @"^(NonGood.*?)( .*?)?.xml";
public static string NonGoodSpecialPattern = @"^(NonGood.*?)( .*)?.dat";
public static string RedumpPattern = @"^(.*?) \((\d{8} \d{2}-\d{2}-\d{2})\)\.dat$";
public static string RedumpBiosPattern = @"^(.*?) \(\d+\) \((\d{4}-\d{2}-\d{2})\)\.dat$";
public static string TosecPattern = @"^(.*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\).*\.dat$";
public static string TosecSpecialPatternA = @"^(.*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\).*\.dat$";
public static string TosecSpecialPatternB = @"^(.*? - .*? - .*?) - .* \(TOSEC-v(\d{4}-\d{2}-\d{2})_CM\).*\.dat$";
public static string TruripPattern = @"^(.*) - .* \(trurip_XML\)\.dat$";
public static string ZandroPattern = @"^SMW-.*.xml";
// Regex Mapped Name Patterns
public static string RemappedPattern = @"^(.*) - (.*)$";
// Regex Date Patterns
public static string DefaultDatePattern = @"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})";
public static string NoIntroDatePattern = @"(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})";
public static string NoIntroSpecialDatePattern = @"(\d{4})(\d{2})(\d{2})";
public static string RedumpDatePattern = @"(\d{4})(\d{2})(\d{2}) (\d{2})-(\d{2})-(\d{2})";
public static string TosecDatePattern = @"(\d{4})-(\d{2})-(\d{2})";
// Regex conversion patterns
public static string HeaderPatternCMP = @"(^.*?) \($";
public static string ItemPatternCMP = @"^\s*(\S*?) (.*)";
public static string EndPatternCMP = @"^\s*\)\s*$";
// Byte (1024-based) size comparisons
public static long KibiByte = 1024;
public static long MibiByte = (long)Math.Pow(KibiByte, 2);
public static long GibiByte = (long)Math.Pow(KibiByte, 3);
public static long TibiByte = (long)Math.Pow(KibiByte, 4);
public static long PibiByte = (long)Math.Pow(KibiByte, 5);
// Byte (1000-based) size comparisons
public static long KiloByte = 1000;
public static long MegaByte = (long)Math.Pow(KiloByte, 2);
public static long GigaByte = (long)Math.Pow(KiloByte, 2);
public static long TeraByte = (long)Math.Pow(KiloByte, 2);
public static long PetaByte = (long)Math.Pow(KiloByte, 2);
}
}

View File

@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SabreTools.Helper
{
/// <summary>
/// Possible DAT import classes
/// </summary>
public enum DatType
{
none = 0,
Custom,
MAME,
NoIntro,
Redump,
TOSEC,
TruRip,
NonGood,
MaybeIntro,
Good,
}
/// <summary>
/// Possible detected header type
/// </summary>
public enum HeaderType
{
None = 0,
A7800,
FDS,
Lynx,
//N64,
NES,
PCE,
PSID,
SNES,
SPC,
}
/// <summary>
/// Severity of the logging statement
/// </summary>
public enum LogLevel
{
VERBOSE = 0,
USER,
WARNING,
ERROR,
}
/// <summary>
/// Determines which type of duplicate a file is
/// </summary>
public enum DupeType
{
None = 0,
InternalHash = 1,
InternalAll = 2,
ExternalHash = 3,
ExternalAll = 4,
}
/// <summary>
/// Determines forcemerging tag for DAT output
/// </summary>
public enum ForceMerging
{
None = 0,
Split,
Full,
}
/// <summary>
/// Determines forcenodump tag for DAT output
/// </summary>
public enum ForceNodump
{
None = 0,
Obsolete,
Required,
Ignore,
}
/// <summary>
/// Determines forcepacking tag for DAT output
/// </summary>
public enum ForcePacking
{
None = 0,
Zip,
Unzip,
}
/// <summary>
/// Determines the DAT output format
/// </summary>
public enum OutputFormat
{
None = 0,
Xml,
ClrMamePro,
RomCenter,
DOSCenter,
MissFile,
SabreDat,
}
}

View File

@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
namespace SabreTools.Helper
{
/// <summary>
/// Intermediate struct for holding and processing rom data
/// </summary>
public struct RomData
{
public string Manufacturer;
public string System;
public int SystemID;
public string Source;
public string URL;
public int SourceID;
public string Game;
public string Name;
public string Type;
public long Size;
public string CRC;
public string MD5;
public string SHA1;
public DupeType Dupe;
public bool Nodump;
public string Date;
}
/// <summary>
/// Intermediate struct for holding DAT information
/// </summary>
public struct DatData : ICloneable
{
// Data common to most DAT types
public string FileName;
public string Name;
public string Description;
public string Category;
public string Version;
public string Date;
public string Author;
public string Email;
public string Homepage;
public string Url;
public string Comment;
public string Header;
public string Type; // Generally only used for SuperDAT
public ForceMerging ForceMerging;
public ForceNodump ForceNodump;
public ForcePacking ForcePacking;
public OutputFormat OutputFormat;
public bool MergeRoms;
public Dictionary<string, List<RomData>> Roms;
// Data specific to the Miss DAT type
public bool UseGame;
public string Prefix;
public string Postfix;
public bool Quotes;
public string RepExt;
public string AddExt;
public bool GameName;
public bool Romba;
public bool TSV; // tab-deliminated output
// Statistical data related to the DAT
public long RomCount;
public long DiskCount;
public long TotalSize;
public long CRCCount;
public long MD5Count;
public long SHA1Count;
public long NodumpCount;
public object Clone()
{
return new DatData
{
FileName = this.FileName,
Name = this.Name,
Description = this.Description,
Category = this.Category,
Version = this.Version,
Date = this.Date,
Author = this.Author,
Email = this.Email,
Homepage = this.Homepage,
Url = this.Url,
Comment = this.Comment,
Header = this.Header,
Type = this.Type,
ForceMerging = this.ForceMerging,
ForceNodump = this.ForceNodump,
ForcePacking = this.ForcePacking,
OutputFormat = this.OutputFormat,
MergeRoms = this.MergeRoms,
Roms = this.Roms,
UseGame = this.UseGame,
Prefix = this.Prefix,
Postfix = this.Postfix,
Quotes = this.Quotes,
RepExt = this.RepExt,
AddExt = this.AddExt,
GameName = this.GameName,
Romba = this.Romba,
TSV = this.TSV,
RomCount = this.RomCount,
DiskCount = this.DiskCount,
TotalSize = this.TotalSize,
CRCCount = this.CRCCount,
MD5Count = this.MD5Count,
SHA1Count = this.SHA1Count,
NodumpCount = this.NodumpCount,
};
}
}
}