mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Centralize quote removal
This commit is contained in:
@@ -1733,13 +1733,11 @@ namespace SabreTools.Helper
|
|||||||
public static void Update(string inputFileName, DatData datdata, string outputDirectory, bool clean, string gamename, string romname,
|
public static void Update(string inputFileName, DatData datdata, string outputDirectory, bool clean, string gamename, string romname,
|
||||||
string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger)
|
string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger)
|
||||||
{
|
{
|
||||||
// Clean the input strings
|
// Clean the input string
|
||||||
inputFileName = inputFileName.Replace("\"", "");
|
|
||||||
if (inputFileName != "")
|
if (inputFileName != "")
|
||||||
{
|
{
|
||||||
inputFileName = Path.GetFullPath(inputFileName);
|
inputFileName = Path.GetFullPath(inputFileName);
|
||||||
}
|
}
|
||||||
outputDirectory = outputDirectory.Replace("\"", "");
|
|
||||||
|
|
||||||
if (File.Exists(inputFileName))
|
if (File.Exists(inputFileName))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace SabreTools
|
|||||||
/// <param name="logger">Logger object for file or console output</param>
|
/// <param name="logger">Logger object for file or console output</param>
|
||||||
public Import(string filepath, string connectionString, Logger logger)
|
public Import(string filepath, string connectionString, Logger logger)
|
||||||
{
|
{
|
||||||
_filepath = filepath.Replace("\"", "");
|
_filepath = filepath;
|
||||||
_connectionString = connectionString;
|
_connectionString = connectionString;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace SabreTools
|
|||||||
_superdat = superdat;
|
_superdat = superdat;
|
||||||
_cascade = cascade;
|
_cascade = cascade;
|
||||||
_inplace = inplace;
|
_inplace = inplace;
|
||||||
_outdir = outdir.Replace("\"", "");
|
_outdir = outdir;
|
||||||
_clean = clean;
|
_clean = clean;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ namespace SabreTools
|
|||||||
/// <param name="logger">Logger object for console and file output</param>
|
/// <param name="logger">Logger object for console and file output</param>
|
||||||
public OfflineMerge (string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake, Logger logger)
|
public OfflineMerge (string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake, Logger logger)
|
||||||
{
|
{
|
||||||
_currentAllMerged = currentAllMerged.Replace("\"", "");
|
_currentAllMerged = currentAllMerged;
|
||||||
_currentMissingMerged = currentMissingMerged.Replace("\"", "");
|
_currentMissingMerged = currentMissingMerged;
|
||||||
_currentNewMerged = currentNewMerged.Replace("\"", "");
|
_currentNewMerged = currentNewMerged;
|
||||||
_fake = fake;
|
_fake = fake;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -365,9 +365,6 @@ namespace SabreTools
|
|||||||
/// <param name="force">True if forcepacking="unzip" should be included</param>
|
/// <param name="force">True if forcepacking="unzip" should be included</param>
|
||||||
private static void InitTrimMerge(string input, string root, bool rename, bool force)
|
private static void InitTrimMerge(string input, string root, bool rename, bool force)
|
||||||
{
|
{
|
||||||
// Strip any quotations from the name
|
|
||||||
input = input.Replace("\"", "");
|
|
||||||
|
|
||||||
if (input != "" && (File.Exists(input) || Directory.Exists(input)))
|
if (input != "" && (File.Exists(input) || Directory.Exists(input)))
|
||||||
{
|
{
|
||||||
TrimMerge sg = new TrimMerge(input, root, rename, force, _logger);
|
TrimMerge sg = new TrimMerge(input, root, rename, force, _logger);
|
||||||
@@ -402,13 +399,13 @@ namespace SabreTools
|
|||||||
List<string> newInputs = new List<string>();
|
List<string> newInputs = new List<string>();
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(input.Replace("\"", "")))
|
if (Directory.Exists(input))
|
||||||
{
|
{
|
||||||
foreach (string file in Directory.EnumerateFiles(input.Replace("\"", ""), "*", SearchOption.AllDirectories))
|
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(input.Replace("\"", "")));
|
newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(input));
|
||||||
}
|
}
|
||||||
catch (PathTooLongException)
|
catch (PathTooLongException)
|
||||||
{
|
{
|
||||||
@@ -420,15 +417,15 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (File.Exists(input.Replace("\"", "")))
|
else if (File.Exists(input))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newInputs.Add(Path.GetFullPath(input.Replace("\"", "")) + "¬" + Path.GetDirectoryName(Path.GetFullPath(input.Replace("\"", ""))));
|
newInputs.Add(Path.GetFullPath(input) + "¬" + Path.GetDirectoryName(Path.GetFullPath(input)));
|
||||||
}
|
}
|
||||||
catch (PathTooLongException)
|
catch (PathTooLongException)
|
||||||
{
|
{
|
||||||
_logger.Warning("The path for " + input.Replace("\"", "") + " was too long");
|
_logger.Warning("The path for " + input + " was too long");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -453,7 +450,7 @@ namespace SabreTools
|
|||||||
// Verify the input files
|
// Verify the input files
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
if (!File.Exists(input.Replace("\"", "")) && !Directory.Exists(input.Replace("\"", "")))
|
if (!File.Exists(input) && !Directory.Exists(input))
|
||||||
{
|
{
|
||||||
_logger.Error(input + " is not a valid file or folder!");
|
_logger.Error(input + " is not a valid file or folder!");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
@@ -462,11 +459,6 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip any quotations from the names
|
|
||||||
exta = exta.Replace("\"", "");
|
|
||||||
extb = extb.Replace("\"", "");
|
|
||||||
outdir = outdir.Replace("\"", "");
|
|
||||||
|
|
||||||
// Convert comma-separated strings to list
|
// Convert comma-separated strings to list
|
||||||
List<string> extaList = exta.Split(',').ToList();
|
List<string> extaList = exta.Split(',').ToList();
|
||||||
List<string> extbList = extb.Split(',').ToList();
|
List<string> extbList = extb.Split(',').ToList();
|
||||||
@@ -483,13 +475,10 @@ namespace SabreTools
|
|||||||
/// <param name="outdir">Output directory for the split files</param>
|
/// <param name="outdir">Output directory for the split files</param>
|
||||||
private static void InitHashSplit(List<string> inputs, string outdir)
|
private static void InitHashSplit(List<string> inputs, string outdir)
|
||||||
{
|
{
|
||||||
// Strip any quotations from the names
|
|
||||||
outdir = outdir.Replace("\"", "");
|
|
||||||
|
|
||||||
// Verify the input files
|
// Verify the input files
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
if (!File.Exists(input.Replace("\"", "")) && !Directory.Exists(input.Replace("\"", "")))
|
if (!File.Exists(input) && !Directory.Exists(input))
|
||||||
{
|
{
|
||||||
_logger.Error(input + " is not a valid file or folder!");
|
_logger.Error(input + " is not a valid file or folder!");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
@@ -512,11 +501,6 @@ namespace SabreTools
|
|||||||
/// <param name="fake">True if all values should be replaced with default 0-byte values, false otherwise</param>
|
/// <param name="fake">True if all values should be replaced with default 0-byte values, false otherwise</param>
|
||||||
private static void InitOfflineMerge(string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake)
|
private static void InitOfflineMerge(string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake)
|
||||||
{
|
{
|
||||||
// Sanitize the inputs
|
|
||||||
currentAllMerged = currentAllMerged.Replace("\"", "");
|
|
||||||
currentMissingMerged = currentMissingMerged.Replace("\"", "");
|
|
||||||
currentNewMerged = currentNewMerged.Replace("\"", "");
|
|
||||||
|
|
||||||
OfflineMerge om = new OfflineMerge(currentAllMerged, currentMissingMerged, currentNewMerged, fake, _logger);
|
OfflineMerge om = new OfflineMerge(currentAllMerged, currentMissingMerged, currentNewMerged, fake, _logger);
|
||||||
bool success = om.Process();
|
bool success = om.Process();
|
||||||
if (!success)
|
if (!success)
|
||||||
@@ -536,15 +520,15 @@ namespace SabreTools
|
|||||||
|
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
if (File.Exists(input.Replace("\"", "")))
|
if (File.Exists(input))
|
||||||
{
|
{
|
||||||
newinputs.Add(input.Replace("\"", ""));
|
newinputs.Add(input);
|
||||||
}
|
}
|
||||||
if (Directory.Exists(input.Replace("\"", "")))
|
if (Directory.Exists(input))
|
||||||
{
|
{
|
||||||
foreach (string file in Directory.GetFiles(input.Replace("\"", ""), "*", SearchOption.AllDirectories))
|
foreach (string file in Directory.GetFiles(input, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
newinputs.Add(file.Replace("\"", ""));
|
newinputs.Add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
version = temparg.Split('=')[1];
|
version = temparg.Split('=')[1];
|
||||||
}
|
}
|
||||||
else if (File.Exists(temparg.Replace("\"", "")) || Directory.Exists(temparg.Replace("\"", "")))
|
else if (File.Exists(temparg) || Directory.Exists(temparg))
|
||||||
{
|
{
|
||||||
inputs.Add(arg);
|
inputs.Add(arg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,7 @@ namespace SabreTools
|
|||||||
public Split(List<string> inputs, List<string> extA, List<string> extB, string outdir, Logger logger)
|
public Split(List<string> inputs, List<string> extA, List<string> extB, string outdir, Logger logger)
|
||||||
{
|
{
|
||||||
_hash = false;
|
_hash = false;
|
||||||
_inputs = new List<string>();
|
_inputs = inputs;
|
||||||
foreach (string s in inputs)
|
|
||||||
{
|
|
||||||
_inputs.Add(s.Replace("\"", ""));
|
|
||||||
}
|
|
||||||
_extA = new List<string>();
|
_extA = new List<string>();
|
||||||
foreach (string s in extA)
|
foreach (string s in extA)
|
||||||
{
|
{
|
||||||
@@ -42,7 +38,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
_extB.Add((s.StartsWith(".") ? s : "." + s).ToUpperInvariant());
|
_extB.Add((s.StartsWith(".") ? s : "." + s).ToUpperInvariant());
|
||||||
}
|
}
|
||||||
_outdir = outdir.Replace("\"", "");
|
_outdir = outdir;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,14 +50,10 @@ namespace SabreTools
|
|||||||
public Split(List<string> inputs, string outdir, Logger logger)
|
public Split(List<string> inputs, string outdir, Logger logger)
|
||||||
{
|
{
|
||||||
_hash = true;
|
_hash = true;
|
||||||
_inputs = new List<string>();
|
_inputs = inputs;
|
||||||
foreach (string s in inputs)
|
|
||||||
{
|
|
||||||
_inputs.Add(s.Replace("\"", ""));
|
|
||||||
}
|
|
||||||
_extA = new List<string>();
|
_extA = new List<string>();
|
||||||
_extB = new List<string>();
|
_extB = new List<string>();
|
||||||
_outdir = outdir.Replace("\"", "");
|
_outdir = outdir;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace SabreTools
|
|||||||
/// <param name="logger">Logger object for console and file output</param>
|
/// <param name="logger">Logger object for console and file output</param>
|
||||||
public TrimMerge(string filename, string path, bool rename, bool forceunpack, Logger logger)
|
public TrimMerge(string filename, string path, bool rename, bool forceunpack, Logger logger)
|
||||||
{
|
{
|
||||||
_filename = filename.Replace("\"", "");
|
_filename = filename;
|
||||||
_path = path;
|
_path = path;
|
||||||
_rename = rename;
|
_rename = rename;
|
||||||
_forceunpack = forceunpack;
|
_forceunpack = forceunpack;
|
||||||
|
|||||||
Reference in New Issue
Block a user