From 3214a26fb12f9815fcba5bccc86b89d265dea74a Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 20 Apr 2016 12:15:57 -0700 Subject: [PATCH] Quotes are for my friends --- DatToMiss/DatToMiss.cs | 8 ++++++-- SabreHelper/Output.cs | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/DatToMiss/DatToMiss.cs b/DatToMiss/DatToMiss.cs index ea7f928e..e6750a2e 100644 --- a/DatToMiss/DatToMiss.cs +++ b/DatToMiss/DatToMiss.cs @@ -34,7 +34,7 @@ namespace SabreTools Build.Start("DatToMiss"); string prefix = "", postfix = "", input = ""; - bool tofile = false, help = false, usegame = true; + bool tofile = false, help = false, usegame = true, quotes = false; foreach (string arg in args) { switch (arg) @@ -52,6 +52,10 @@ namespace SabreTools case "--roms": usegame = false; break; + case "-q": + case "--quotes": + quotes = true; + break; default: if ((arg.StartsWith("-pre=") || arg.StartsWith("--prefix=")) && prefix == "") { @@ -89,7 +93,7 @@ namespace SabreTools name += Path.GetFileNameWithoutExtension(input) + "-miss.txt"; // Read in the roms from the DAT and then write them to the file - Output.WriteToText(name, Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix); + Output.WriteToText(name, Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix, quotes); } } } diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs index 16a09197..13d1e643 100644 --- a/SabreHelper/Output.cs +++ b/SabreHelper/Output.cs @@ -136,8 +136,9 @@ namespace SabreTools.Helper /// True if only games are written to text file (default), false for files only /// Arbitrary string to prefix each line /// Arbitrary string to postfix each line + /// True if quotes should be put around the item, false otherwise (default) /// True if the file was written, false otherwise - public static bool WriteToText(string textfile, string outdir, List roms, Logger logger, bool useGame = true, string prefix = "", string postfix = "") + public static bool WriteToText(string textfile, string outdir, List roms, Logger logger, bool useGame = true, string prefix = "", string postfix = "", bool quotes = false) { // Normalize the output directory if (outdir == "") @@ -167,12 +168,12 @@ namespace SabreTools.Helper { if (useGame && rom.Game != lastgame) { - sw.WriteLine(prefix + rom.Game + postfix); + sw.WriteLine(prefix + (quotes ? "\"" : "") + rom.Game + (quotes ? "\"" : "") + postfix); lastgame = rom.Game; } else if (!useGame) { - sw.WriteLine(prefix + rom.Name + postfix); + sw.WriteLine(prefix + (quotes ? "\"" : "") + rom.Name + (quotes ? "\"" : "")+ postfix); } }