diff --git a/DATabase/Core/Generate.cs b/DATabase/Core/Generate.cs
index 07cb27e1..b6a6577c 100644
--- a/DATabase/Core/Generate.cs
+++ b/DATabase/Core/Generate.cs
@@ -11,6 +11,9 @@ using SabreTools.Helper;
namespace SabreTools
{
+ ///
+ /// Generate a DAT from the data in the database
+ ///
class Generate
{
// Private instance variables
@@ -24,6 +27,15 @@ namespace SabreTools
private Dictionary _headers;
private Logger _logger;
+ ///
+ /// Initialize a Generate object with the given information
+ ///
+ /// Comma-separated list of systems to be included in the DAT (blank means all)
+ /// Comma-separated list of sources to be included in the DAT (blank means all)
+ /// Connection string for SQLite
+ /// Logger object for file or console output
+ /// True if files should not be renamed with system and/or source in merged mode (default false)
+ /// True if the output file should be in RomVault format (default false)
public Generate(string systems, string sources, string connectionString, Logger logger, bool norename = false, bool old = false)
{
_systems = systems;
@@ -43,6 +55,10 @@ namespace SabreTools
_headers.Add(241, "snes.xml"); // Self-created to deal with various headers
}
+ ///
+ /// Generate a DAT file that is represented by the data in the Generate object.
+ ///
+ /// True if the file could be created, false otherwise
public bool Export()
{
// Check to see if the source is an import-only. If so, tell the user and exit
@@ -251,6 +267,10 @@ namespace SabreTools
return true;
}
+ ///
+ /// Preprocess the rom data that is to be included in the outputted DAT
+ ///
+ /// A List of RomData objects containing all information about the files
public List ProcessRoms()
{
List roms = new List();
@@ -429,7 +449,9 @@ JOIN checksums
}
}
- // Intermediate struct for holding and processing rom data
+ ///
+ /// Intermediate struct for holding and processing rom data
+ ///
public struct RomData
{
public string Manufacturer;
diff --git a/DATabase/Core/Import.cs b/DATabase/Core/Import.cs
index 0e9af8b1..f995ef22 100644
--- a/DATabase/Core/Import.cs
+++ b/DATabase/Core/Import.cs
@@ -32,6 +32,10 @@ namespace SabreTools
7) You should be done! Unless your DAT is of a custom format, it should be taken care of on import.
i. If custom handling is needed on import, look for "SuperDAT" for an example
*/
+
+ ///
+ /// Import data into the database from existing DATs
+ ///
public class Import
{
// Private instance variables
@@ -56,6 +60,9 @@ namespace SabreTools
private static string _redumpDatePattern = @"(\d{4})(\d{2})(\d{2}) (\d{2})-(\d{2})-(\d{2})";
private static string _tosecDatePattern = @"(\d{4})-(\d{2})-(\d{2})";
+ ///
+ /// Possible DAT import classes
+ ///
private enum DatType
{
none = 0,
@@ -73,7 +80,12 @@ namespace SabreTools
get { return _filepath; }
}
- // Constructor
+ ///
+ /// Initialize an Import object with the given information
+ ///
+ /// Path to the file that is going to be imported
+ /// Connection string for SQLite
+ /// Logger object for file or console output
public Import(string filepath, string connectionString, Logger logger)
{
if (File.Exists(filepath))
@@ -89,7 +101,10 @@ namespace SabreTools
_logger = logger;
}
- // Import the data from file into the database
+ ///
+ /// Import the data from file into the database
+ ///
+ /// True if the data was imported, false otherwise
public bool ImportData ()
{
// Determine which dattype we have
@@ -353,7 +368,7 @@ namespace SabreTools
// If we find a rom or disk, add it
if (node.NodeType == XmlNodeType.Element && (child.Name == "rom" || child.Name == "disk"))
{
- AddRomHelper(
+ AddRom(
child.Name,
gameid,
child.Attributes["name"].Value,
@@ -377,7 +392,7 @@ namespace SabreTools
// If we find a rom or disk, add it
if (data.NodeType == XmlNodeType.Element && (data.Name == "rom" || data.Name == "disk"))
{
- AddRomHelper(
+ AddRom(
data.Name,
gameid,
data.Attributes["name"].Value,
@@ -401,6 +416,13 @@ namespace SabreTools
return true;
}
+ ///
+ /// Add a game to the database if it doesn't already exist
+ ///
+ /// System ID for the game to be added with
+ /// Name of the game to be added
+ /// Source ID for the game to be added with
+ /// Game ID of the inserted (or found) game, -1 on error
private long AddGame(int sysid, string machinename, int srcid)
{
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same
@@ -457,7 +479,19 @@ namespace SabreTools
return gameid;
}
- private bool AddRomHelper(string romtype, long gameid, string name, string date, int size, string crc, string md5, string sha1)
+ ///
+ /// Add a file to the database if it doesn't already exist
+ ///
+ /// File type (either "rom" or "disk")
+ /// ID of the parent game to be mapped to
+ /// File name
+ /// Last updated date
+ /// File size in bytes
+ /// CRC32 hash of the file
+ /// MD5 hash of the file
+ /// SHA-1 hash of the file
+ /// True if the file exists or could be added, false on error
+ private bool AddRom(string romtype, long gameid, string name, string date, int size, string crc, string md5, string sha1)
{
// WOD origninally stripped out any subdirs from the imported files, we do the same
name = Path.GetFileName(name);
diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs
index c8686f8f..db024f17 100644
--- a/DATabase/DATabase.cs
+++ b/DATabase/DATabase.cs
@@ -7,6 +7,9 @@ using SabreTools.Helper;
namespace SabreTools
{
+ ///
+ /// Entry class for the DATabase application
+ ///
class DATabase
{
private static Logger logger;
@@ -22,7 +25,11 @@ namespace SabreTools
+-----------------------------------------------------------------------------+
";
- static void Main(string[] args)
+ ///
+ /// Start menu or use supplied parameters
+ ///
+ /// String array representing command line parameters
+ public static void Main(string[] args)
{
// Perform initial setup and verification
logger = new Logger(false, "database.log");
@@ -169,6 +176,9 @@ namespace SabreTools
return;
}
+ ///
+ /// Print the program header
+ ///
private static void PrintHeader()
{
ConsoleColor formertext = Console.ForegroundColor;
@@ -180,6 +190,9 @@ namespace SabreTools
Console.BackgroundColor = formerback;
}
+ ///
+ /// Show the text-based main menu
+ ///
private static void ShowMainMenu()
{
Console.Clear();
@@ -249,6 +262,9 @@ Make a selection:
Console.WriteLine("Thank you for using DATabase!");
}
+ ///
+ /// Show the help dialog
+ ///
private static void Help()
{
Console.Clear();
@@ -294,6 +310,9 @@ Database Options:
return;
}
+ ///
+ /// Show the text-based import menu
+ ///
private static void ImportMenu()
{
string selection = "";
@@ -317,6 +336,10 @@ or 'b' to go back to the previous menu:");
return;
}
+ ///
+ /// Wrap importing a file or folder into the database
+ ///
+ /// File or folder to be imported
private static void InitImport(string filename)
{
Console.Clear();
@@ -347,6 +370,9 @@ or 'b' to go back to the previous menu:");
return;
}
+ ///
+ /// Show the text-based generate menu
+ ///
private static void GenerateMenu()
{
string selection = "", systems = "", sources = "";
@@ -399,6 +425,23 @@ Make a selection:
return;
}
+ ///
+ /// Wrap generating a DAT from the database
+ ///
+ /// Comma-separated list of systems to be included in the DAT (blank means all)
+ /// Comma-separated list of sources to be included in the DAT (blank means all)
+ /// True if files should not be renamed with system and/or source in merged mode (default false)
+ /// True if the output file should be in RomVault format (default false)
+ private static void InitGenerate(string systems, string sources, bool norename, bool old)
+ {
+ Generate gen = new Generate(systems, sources, _connectionString, logger, norename, old);
+ gen.Export();
+ return;
+ }
+
+ ///
+ /// Show the text-based generate all menu
+ ///
private static void GenerateAllMenu()
{
string selection = "";
@@ -437,14 +480,11 @@ Make a selection:
return;
}
- /// TODO: Make this safe for auto-generating multiple files (such as auto-generate)
- private static void InitGenerate(string systems, string sources, bool norename, bool old)
- {
- Generate gen = new Generate(systems, sources, _connectionString, logger, norename, old);
- gen.Export();
- return;
- }
-
+ ///
+ /// Wrap generating all standard DATs from the database
+ ///
+ /// True if files should not be renamed with system and/or source in merged mode (default false)
+ /// True if the output file should be in RomVault format (default false)
private static void InitGenerateAll(bool norename, bool old)
{
// Generate system-merged
@@ -533,6 +573,9 @@ Make a selection:
return;
}
+ ///
+ /// Show the text-based conversion menu
+ ///
private static void ConvertMenu()
{
string selection = "";
@@ -557,6 +600,10 @@ or 'b' to go back to the previous menu:
return;
}
+ ///
+ /// Wrap converting DAT file from RomValut to XML
+ ///
+ ///
private static void InitConvert(string filename)
{
if (File.Exists(filename))
@@ -579,6 +626,10 @@ or 'b' to go back to the previous menu:
return;
}
+ ///
+ /// List sources in the database
+ ///
+ /// True to list all sources regardless if there is a game associated or not
private static void ListSources(bool all = false)
{
string query = @"
@@ -610,6 +661,10 @@ ORDER BY sources.name COLLATE NOCASE";
return;
}
+ ///
+ /// List systems in the database
+ ///
+ /// True to list all systems regardless if there is a game associated or not
private static void ListSystems(bool all = false)
{
string query = @"
@@ -641,6 +696,9 @@ ORDER BY systems.manufacturer, systems.system";
return;
}
+ ///
+ /// Show the text-based add and remove menu
+ ///
private static void AddRemoveMenu()
{
string selection = "", manufacturer = "", system = "", name = "", url = "";
@@ -703,6 +761,11 @@ Make a selection:
return;
}
+ ///
+ /// Wrap adding a new source to the database
+ ///
+ /// Source name
+ /// Source URL(s)
private static void InitAddSource(string name, string url)
{
if (DBTools.AddSource(name, url, _connectionString))
@@ -715,6 +778,10 @@ Make a selection:
}
}
+ ///
+ /// Wrap removing an existing source from the database
+ ///
+ /// Source ID to be removed from the database
private static void InitRemoveSource(string sourceid)
{
int srcid = -1;
@@ -735,6 +802,11 @@ Make a selection:
}
}
+ ///
+ /// Wrap adding a new system to the database
+ ///
+ /// Manufacturer name
+ /// System name
private static void InitAddSystem(string manufacturer, string system)
{
if (DBTools.AddSystem(manufacturer, system, _connectionString))
@@ -747,6 +819,10 @@ Make a selection:
}
}
+ ///
+ /// Wrap removing an existing system from the database
+ ///
+ /// System ID to be removed from the database
private static void InitRemoveSystem(string systemid)
{
int sysid = -1;
diff --git a/DATabase/Helper/Converters.cs b/DATabase/Helper/Converters.cs
index 012afb6b..085d3c23 100644
--- a/DATabase/Helper/Converters.cs
+++ b/DATabase/Helper/Converters.cs
@@ -4,13 +4,22 @@ using System.Xml.Linq;
namespace SabreTools.Helper
{
+ ///
+ /// Provide DAT conversion functionality
+ ///
class Converters
{
+ // Regex matching patterns
private static string _headerPattern = @"(^.*?) \($";
private static string _romPattern = @"^\s+((?:rom)|(?:disk)) \( (name) ""(.*?)"" (?:(size) (.*?) )?(?:(crc) (.*?))?(?:(md5) (.*?) )?(?:(sha1) (.*?) )?\)";
private static string _itemPattern = @"^\s+(.*?) ""(.*?)""";
private static string _endPattern = @"^\s*\)\s*$";
+ ///
+ /// Convert a RomVault style DAT to an XML derived DAT
+ ///
+ /// Array of strings representing the input file
+ /// XElement representing the output XML DAT file
public static XElement RomVaultToXML (string[] filecontents)
{
XElement elem = new XElement("datafile");
diff --git a/DATabase/Helper/DBTools.cs b/DATabase/Helper/DBTools.cs
index b3dbad9a..30e54fcb 100644
--- a/DATabase/Helper/DBTools.cs
+++ b/DATabase/Helper/DBTools.cs
@@ -4,8 +4,16 @@ using System.IO;
namespace SabreTools.Helper
{
+ ///
+ /// All general database operations
+ ///
class DBTools
{
+ ///
+ /// Ensure that the databse exists and has the proper schema
+ ///
+ /// Name of the databse
+ /// Connection string for SQLite
public static void EnsureDatabase(string db, string connectionString)
{
// Make sure the file exists
@@ -91,6 +99,13 @@ CREATE TABLE IF NOT EXISTS systems (
}
}
+ ///
+ /// Add a new source to the database if it doesn't already exist
+ ///
+ /// Source name
+ /// Source URL(s)
+ /// Connection string for SQLite
+ /// True if the source existed or could be added, false otherwise
public static bool AddSource(string name, string url, string connectionString)
{
string query = "SELECT id, name, url FROM sources WHERE name='" + name + "'";
@@ -130,6 +145,12 @@ CREATE TABLE IF NOT EXISTS systems (
return true;
}
+ ///
+ /// Remove an existing source from the database
+ ///
+ /// Source ID to be removed from the database
+ /// Connection string for SQLite
+ /// True if the source was removed, false otherwise
public static bool RemoveSource(int id, string connectionString)
{
string query = "DELETE FROM sources WHERE id=" + id;
@@ -143,6 +164,13 @@ CREATE TABLE IF NOT EXISTS systems (
}
}
+ ///
+ /// Add a new system to the database if it doesn't already exist
+ ///
+ /// Manufacturer name
+ /// System name
+ /// Connection string for SQLite
+ /// True if the system existed or could be added, false otherwise
public static bool AddSystem(string manufacturer, string system, string connectionString)
{
string query = "SELECT id, manufacturer, system FROM systems WHERE manufacturer='" + manufacturer + "' AND system='" + system + "'";
@@ -168,6 +196,12 @@ CREATE TABLE IF NOT EXISTS systems (
return true;
}
+ ///
+ /// Remove an existing system from the database
+ ///
+ /// System ID to be removed from the database
+ /// Connection string for SQLite
+ /// True if the system was removed, false otherwise
public static bool RemoveSystem(int id, string connectionString)
{
string query = "DELETE FROM systems WHERE id=" + id;
diff --git a/DATabase/Helper/Logger.cs b/DATabase/Helper/Logger.cs
index b6f7b4ef..2fe98a1a 100644
--- a/DATabase/Helper/Logger.cs
+++ b/DATabase/Helper/Logger.cs
@@ -3,6 +3,9 @@ using System.IO;
namespace SabreTools.Helper
{
+ ///
+ /// Log either to file or to the console
+ ///
public class Logger
{
// Private instance variables
@@ -28,12 +31,21 @@ namespace SabreTools.Helper
}
}
+ ///
+ /// Initialize a Logger object with the given information
+ ///
+ /// True if file should be written to instead of console
+ /// Optional filename representing log location
public Logger(bool tofile, string filename = "")
{
_tofile = tofile;
_filename = filename;
}
+ ///
+ /// Start logging by opening output file (if necessary)
+ ///
+ /// True if the logging was started correctly, false otherwise
public bool Start()
{
if (!_tofile)
@@ -54,6 +66,10 @@ namespace SabreTools.Helper
return true;
}
+ ///
+ /// End logging by closing output file (if necessary)
+ ///
+ /// True if the logging was ended correctly, false otherwise
public bool Close()
{
if (!_tofile)
@@ -74,6 +90,11 @@ namespace SabreTools.Helper
return true;
}
+ ///
+ /// Write the given string to the log output
+ ///
+ /// String to be written log
+ /// True if the output could be written, false otherwise
public bool Log(string output)
{
// If we're writing to console, just write the string
diff --git a/DATabase/Helper/Remapping.cs b/DATabase/Helper/Remapping.cs
index d7c0477e..c1427da1 100644
--- a/DATabase/Helper/Remapping.cs
+++ b/DATabase/Helper/Remapping.cs
@@ -5,14 +5,21 @@ using System.Xml;
namespace SabreTools.Helper
{
+ ///
+ /// Contains all remappings of known import classes
+ ///
class Remapping
{
+ // Remapping classes represented by dictionaries
public static Dictionary MAME = new Dictionary();
public static Dictionary NoIntro = new Dictionary();
public static Dictionary Redump = new Dictionary();
public static Dictionary TOSEC = new Dictionary();
public static Dictionary TruRip = new Dictionary();
+ ///
+ /// Create all remappings to be used by the program
+ ///
public static void CreateRemappings()
{
// Create array of dictionary names
@@ -28,6 +35,10 @@ namespace SabreTools.Helper
}
}
+ ///
+ /// Create a remapping from XML
+ ///
+ /// Name of the mapping to be populated
private static void RemappingHelper(string mapping)
{
// Read in remapping from file
diff --git a/DATabase/Helper/Style.cs b/DATabase/Helper/Style.cs
index fe6cf585..c6665450 100644
--- a/DATabase/Helper/Style.cs
+++ b/DATabase/Helper/Style.cs
@@ -2,9 +2,16 @@
namespace SabreTools.Helper
{
+ ///
+ /// Include character normalization and replacement mappings
+ ///
public class Style
{
- // Replace accented characters
+ ///
+ /// Replace accented characters
+ ///
+ /// String to be parsed
+ /// String with characters replaced
public static string NormalizeChars(string input)
{
string[,] charmap = {
@@ -53,7 +60,11 @@ namespace SabreTools.Helper
return input;
}
- // Replace special characters and patterns
+ ///
+ /// Replace special characters and patterns
+ ///
+ /// String to be parsed
+ /// String with characters replaced
public static string SearchPattern(string input)
{
string[,] charmap = {
@@ -93,8 +104,12 @@ namespace SabreTools.Helper
return input;
}
- // Convert Cyrillic lettering to Latin lettering
- public static string RussianToLatin (string input)
+ ///
+ /// Convert Cyrillic lettering to Latin lettering
+ ///
+ /// String to be parsed
+ /// String with characters replaced
+ public static string RussianToLatin(string input)
{
string [,] charmap = {
{ "А", "A" }, { "Б", "B" }, { "В", "V" }, { "Г", "G" }, { "Д", "D" },
diff --git a/Deheader/Deheader.cs b/Deheader/Deheader.cs
index 0e115ec8..03e9487e 100644
--- a/Deheader/Deheader.cs
+++ b/Deheader/Deheader.cs
@@ -6,12 +6,19 @@ using System.Text.RegularExpressions;
namespace SabreTools
{
+ ///
+ /// Entry class for the Deheader application
+ ///
class Deheader
{
private static Dictionary types;
private static bool save;
private static string help = @"Deheader.exe [-s] filename|dirname";
+ ///
+ /// Start deheader operation with supplied parameters
+ ///
+ /// String array representing command line parameters
static void Main(string[] args)
{
// Type mapped to header size (in decimal bytes)
@@ -65,6 +72,10 @@ namespace SabreTools
}
}
+ ///
+ /// Detect and remove header from the given file
+ ///
+ /// Name of the file to be parsed
private static void DetectRemoveHeader(string file)
{
// Open the file in read mode