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,
|
||||
string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger)
|
||||
{
|
||||
// Clean the input strings
|
||||
inputFileName = inputFileName.Replace("\"", "");
|
||||
// Clean the input string
|
||||
if (inputFileName != "")
|
||||
{
|
||||
inputFileName = Path.GetFullPath(inputFileName);
|
||||
}
|
||||
outputDirectory = outputDirectory.Replace("\"", "");
|
||||
|
||||
if (File.Exists(inputFileName))
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace SabreTools
|
||||
/// <param name="logger">Logger object for file or console output</param>
|
||||
public Import(string filepath, string connectionString, Logger logger)
|
||||
{
|
||||
_filepath = filepath.Replace("\"", "");
|
||||
_filepath = filepath;
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace SabreTools
|
||||
_superdat = superdat;
|
||||
_cascade = cascade;
|
||||
_inplace = inplace;
|
||||
_outdir = outdir.Replace("\"", "");
|
||||
_outdir = outdir;
|
||||
_clean = clean;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace SabreTools
|
||||
/// <param name="logger">Logger object for console and file output</param>
|
||||
public OfflineMerge (string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake, Logger logger)
|
||||
{
|
||||
_currentAllMerged = currentAllMerged.Replace("\"", "");
|
||||
_currentMissingMerged = currentMissingMerged.Replace("\"", "");
|
||||
_currentNewMerged = currentNewMerged.Replace("\"", "");
|
||||
_currentAllMerged = currentAllMerged;
|
||||
_currentMissingMerged = currentMissingMerged;
|
||||
_currentNewMerged = currentNewMerged;
|
||||
_fake = fake;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -365,9 +365,6 @@ namespace SabreTools
|
||||
/// <param name="force">True if forcepacking="unzip" should be included</param>
|
||||
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)))
|
||||
{
|
||||
TrimMerge sg = new TrimMerge(input, root, rename, force, _logger);
|
||||
@@ -402,13 +399,13 @@ namespace SabreTools
|
||||
List<string> newInputs = new List<string>();
|
||||
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
|
||||
{
|
||||
newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(input.Replace("\"", "")));
|
||||
newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(input));
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
@@ -420,15 +417,15 @@ namespace SabreTools
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (File.Exists(input.Replace("\"", "")))
|
||||
else if (File.Exists(input))
|
||||
{
|
||||
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)
|
||||
{
|
||||
_logger.Warning("The path for " + input.Replace("\"", "") + " was too long");
|
||||
_logger.Warning("The path for " + input + " was too long");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -453,7 +450,7 @@ namespace SabreTools
|
||||
// Verify the input files
|
||||
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!");
|
||||
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
|
||||
List<string> extaList = exta.Split(',').ToList();
|
||||
List<string> extbList = extb.Split(',').ToList();
|
||||
@@ -483,13 +475,10 @@ namespace SabreTools
|
||||
/// <param name="outdir">Output directory for the split files</param>
|
||||
private static void InitHashSplit(List<string> inputs, string outdir)
|
||||
{
|
||||
// Strip any quotations from the names
|
||||
outdir = outdir.Replace("\"", "");
|
||||
|
||||
// Verify the input files
|
||||
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!");
|
||||
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>
|
||||
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);
|
||||
bool success = om.Process();
|
||||
if (!success)
|
||||
@@ -536,15 +520,15 @@ namespace SabreTools
|
||||
|
||||
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];
|
||||
}
|
||||
else if (File.Exists(temparg.Replace("\"", "")) || Directory.Exists(temparg.Replace("\"", "")))
|
||||
else if (File.Exists(temparg) || Directory.Exists(temparg))
|
||||
{
|
||||
inputs.Add(arg);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,7 @@ namespace SabreTools
|
||||
public Split(List<string> inputs, List<string> extA, List<string> extB, string outdir, Logger logger)
|
||||
{
|
||||
_hash = false;
|
||||
_inputs = new List<string>();
|
||||
foreach (string s in inputs)
|
||||
{
|
||||
_inputs.Add(s.Replace("\"", ""));
|
||||
}
|
||||
_inputs = inputs;
|
||||
_extA = new List<string>();
|
||||
foreach (string s in extA)
|
||||
{
|
||||
@@ -42,7 +38,7 @@ namespace SabreTools
|
||||
{
|
||||
_extB.Add((s.StartsWith(".") ? s : "." + s).ToUpperInvariant());
|
||||
}
|
||||
_outdir = outdir.Replace("\"", "");
|
||||
_outdir = outdir;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -54,14 +50,10 @@ namespace SabreTools
|
||||
public Split(List<string> inputs, string outdir, Logger logger)
|
||||
{
|
||||
_hash = true;
|
||||
_inputs = new List<string>();
|
||||
foreach (string s in inputs)
|
||||
{
|
||||
_inputs.Add(s.Replace("\"", ""));
|
||||
}
|
||||
_inputs = inputs;
|
||||
_extA = new List<string>();
|
||||
_extB = new List<string>();
|
||||
_outdir = outdir.Replace("\"", "");
|
||||
_outdir = outdir;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace SabreTools
|
||||
/// <param name="logger">Logger object for console and file output</param>
|
||||
public TrimMerge(string filename, string path, bool rename, bool forceunpack, Logger logger)
|
||||
{
|
||||
_filename = filename.Replace("\"", "");
|
||||
_filename = filename;
|
||||
_path = path;
|
||||
_rename = rename;
|
||||
_forceunpack = forceunpack;
|
||||
|
||||
Reference in New Issue
Block a user