diff --git a/CatalogPlugin.cs b/CatalogPlugin.cs index c5895ff..c238ee8 100644 --- a/CatalogPlugin.cs +++ b/CatalogPlugin.cs @@ -230,7 +230,7 @@ public static void Process(CatalogOptions options) { var key = $"{hex1}{hex2}"; - File.AppendAllLines($"{options.OutputFolder}\\{options.Prefix}-{key}.txt", buckets[key]); + File.AppendAllLines(Path.Combine(options.OutputFolder,$"{options.Prefix}-{key}.txt"), buckets[key]); buckets[key].Clear(); } } @@ -253,7 +253,7 @@ public static void Process(CatalogOptions options) private static async Task DoXReference(CatalogOptions options) { - var xrefFolder = $"{options.OutputFolder}\\xref\\"; + var xrefFolder = $"{options.OutputFolder}{Path.DirectorySeparatorChar}xref{Path.DirectorySeparatorChar}"; if (!Directory.Exists(xrefFolder)) { WriteMessage($"Creating new xref folder at {xrefFolder}"); @@ -283,7 +283,7 @@ private static async Task DoXReference(CatalogOptions options) foreach (var hex2 in Hex) { var key = $"{hex1}{hex2}"; - var path = $"{options.OutputFolder}\\{options.Prefix}-{key}.txt"; + var path = Path.Combine(options.OutputFolder, $"{options.Prefix}-{key}.txt"); tasks.Add(CalculateXRef(path, options)); } @@ -313,8 +313,8 @@ private static async Task DoXReference(CatalogOptions options) foreach (var hex2 in Hex) { var key = $"{hex1}{hex2}"; - var mapPath = $"{options.OutputFolder}\\xref\\{options.Prefix}-xref-{key}.tmp"; - var outputPath = $"{options.OutputFolder}\\xref\\{options.Prefix}-xref-{key}.txt"; + var mapPath = Path.Combine(options.OutputFolder, "xref", $"{options.Prefix}-xref-{key}.tmp"); + var outputPath = Path.Combine(options.OutputFolder, "xref", $"{options.Prefix}-xref-{key}.txt"); tasks.Add(OptimiseFile(mapPath, outputPath)); } @@ -492,7 +492,7 @@ private static async Task WriteFiles(Dictionary> //Loop through each de, lock and write out the lines foreach (var de in output) { - var path = $"{options.OutputFolder}\\xref\\{options.Prefix}-xref-{de.Key}.tmp"; + var path = Path.Combine(options.OutputFolder, "xref", "${options.Prefix}-xref-{de.Key}.tmp"); //https://blog.cdemi.io/async-waiting-inside-c-sharp-locks/ try diff --git a/CutPlugin.cs b/CutPlugin.cs index abcd768..6978014 100644 --- a/CutPlugin.cs +++ b/CutPlugin.cs @@ -30,8 +30,8 @@ public static void Process(CutOptions options) var fileInfo = new FileInfo(filePath); var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; - var outputPath = $"{currentDirectory}\\{options.OutputPath}"; + var filePathName = Path.Combine(currentDirectory, fileName); + var outputPath = Path.Combine(currentDirectory, options.OutputPath); //Check that there are no output files if (!CheckForFiles(new string[] { outputPath })) diff --git a/ExportPlugin.cs b/ExportPlugin.cs index cb9fa23..cfbdece 100644 --- a/ExportPlugin.cs +++ b/ExportPlugin.cs @@ -169,9 +169,9 @@ public static void Process(ExportOptions options) foreach (var hashesPath in hashFileEntries) { var fileName = Path.GetFileNameWithoutExtension(hashesPath); - var plainsPath = $"{currentDirectory}\\{fileName}.plains.txt"; //email:plain - var foundPath = $"{currentDirectory}\\{fileName}.found.txt"; //hash:plain - var leftPath = $"{currentDirectory}\\{IncrementFilename(fileName, "left")}.txt"; //hash + var plainsPath = Path.Combine(currentDirectory, $"{fileName}.plains.txt"); //email:plain + var foundPath = Path.Combine(currentDirectory, $"{fileName}.found.txt"); //hash:plain + var leftPath = Path.Combine(currentDirectory, $"{IncrementFilename(fileName, "left")}.txt"); //hash //Check that there are no output files if (!CheckForFiles(new string[] { plainsPath, foundPath, leftPath})) @@ -317,14 +317,14 @@ public static void Process(ExportOptions options) if (removeHashes.Count > 0) { var removeHashesFileName = Path.GetFileNameWithoutExtension(options.RemoveHashesPath); - var removeHashesNewPath = $"{currentDirectory}\\{IncrementFilename(removeHashesFileName, "left")}.hash"; //hash + var removeHashesNewPath = Path.Combine(currentDirectory, $"{IncrementFilename(removeHashesFileName, "left")}.hash"); //hash File.AppendAllLines(removeHashesNewPath, removeHashes); if (removeWords.Count > 0) { var removeWordsFileName = Path.GetFileNameWithoutExtension(options.RemoveWordsPath); - var removeWordsNewPath = $"{currentDirectory}\\{IncrementFilename(removeWordsFileName, "left")}.word"; //word + var removeWordsNewPath = Path.Combine(currentDirectory, $"{IncrementFilename(removeWordsFileName, "left")}.word"); //word File.AppendAllLines(removeWordsNewPath, removeWords); } diff --git a/HashPlugin.cs b/HashPlugin.cs index dee3c0c..0b96231 100644 --- a/HashPlugin.cs +++ b/HashPlugin.cs @@ -24,7 +24,7 @@ public static void Process(HashOptions options) //Create a version based on the file size, so that the hash and dict are bound together var fileInfo = new FileInfo(filePath); var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); var lineCount = 0; var output = new List(); diff --git a/LookupPlugin.cs b/LookupPlugin.cs index 2f16b8d..724c84e 100644 --- a/LookupPlugin.cs +++ b/LookupPlugin.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; @@ -123,7 +124,7 @@ public static void Process(LookupOptions options) //Create a version based on the file size, so that the hash and dict are bound together var fileInfo = new FileInfo(filePath); var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); var outputHashPath = $"{filePathName}{variation}.hash"; var outputWordPath = $"{filePathName}{variation}.word"; @@ -207,7 +208,7 @@ public static void Process(LookupOptions options) foreach (var hex2 in Hex) { var key = $"{hex1}{hex2}"; - var sourcePath = $"{options.SourceFolder}\\{options.Prefix}-{key}.txt"; + var sourcePath = Path.Combine(options.SourceFolder, $"{options.Prefix}-{key}.txt"); DoLookup(key, currentDirectory, variation, sourcePath, lookups, options, rules); bucketCount++; @@ -360,7 +361,7 @@ private static void DoLookup(string key, string currentDirectory, string variati { if (lookup.Hashes.Count != lookup.Words.Count) throw new ApplicationException("Hashes count does not match wordlist count."); - var filePathName = $"{currentDirectory}\\{lookup.Filename}"; + var filePathName = Path.Combine(currentDirectory, lookup.Filename); if (options.Export) { @@ -452,7 +453,7 @@ private static List InferWords(List words, LookupOptions options var key = hash[0].ToString("x2"); //Get the file name - var path = $"{options.SourceFolder}\\xref\\{options.Prefix}-xref-{key}.txt"; + var path = Path.Combine(options.SourceFolder, "xref", $"{options.Prefix}-xref-{key}.txt"); //Check if the indexes have been calculated if (!_inferenceIndex.ContainsKey(key)) _inferenceIndex.Add(key, CalculateInferenceFileIndexes(key, path)); diff --git a/MapPlugin.cs b/MapPlugin.cs index 611c017..d610f2a 100644 --- a/MapPlugin.cs +++ b/MapPlugin.cs @@ -73,7 +73,7 @@ public static void Process(MapOptions options) //Create a version based on the file size, so that the hash and dict are bound together var fileInfo = new FileInfo(filePath); var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); _outputHashPath = $"{filePathName}.{version}.hash"; _outputWordPath = $"{filePathName}.{version}.word"; diff --git a/ParsePlugin.cs b/ParsePlugin.cs index 2cc8a48..3438acf 100644 --- a/ParsePlugin.cs +++ b/ParsePlugin.cs @@ -51,7 +51,7 @@ public static void Process(ParseOptions options) //Create a version based on the file size, so that the hash and dict are bound together var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); var outputPath = $"{filePathName}.parse.txt"; var outputNotParsedPath = $"{filePathName}.noparse.txt"; diff --git a/Program.cs b/Program.cs index e34c7cc..fb26442 100644 --- a/Program.cs +++ b/Program.cs @@ -103,7 +103,7 @@ private static Assembly LoadPlugin(string name) { // Navigate up to the solution root //var pluginFolder = $"{Directory.GetCurrentDirectory()}\\Plugins\\"; - var pluginFolder = $"{AppDomain.CurrentDomain.BaseDirectory}\\Plugins\\{name}\\"; + var pluginFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", name) + Path.DirectorySeparatorChar; if (!Directory.Exists(pluginFolder)) { diff --git a/RankPlugin.cs b/RankPlugin.cs index 26c54f3..7c4032c 100644 --- a/RankPlugin.cs +++ b/RankPlugin.cs @@ -146,7 +146,7 @@ public static void Process(RankOptions options) } var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); if (lines.Count > 0) { diff --git a/SortPlugin.cs b/SortPlugin.cs index 3c8cf58..a79a647 100644 --- a/SortPlugin.cs +++ b/SortPlugin.cs @@ -24,7 +24,7 @@ public static void Process(SortOptions options) //Create a version based on the file size, so that the hash and dict are bound together var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); var outputPath = $"{filePathName}.temp.txt"; diff --git a/SplitPlugin.cs b/SplitPlugin.cs index 0c48729..2ccbdfa 100644 --- a/SplitPlugin.cs +++ b/SplitPlugin.cs @@ -33,7 +33,7 @@ public static void Process(SplitOptions options) //Create a version based on the file size, so that the hash and dict are bound together var fileInfo = new FileInfo(filePath); var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); var lineCount = 0; var part = 1; diff --git a/SqlPlugin.cs b/SqlPlugin.cs index 89fc996..2aa3d8b 100644 --- a/SqlPlugin.cs +++ b/SqlPlugin.cs @@ -55,7 +55,7 @@ public static void Process(SqlOptions options) WriteMessage($"Processing {sqlPath}."); var fileName = Path.GetFileNameWithoutExtension(sqlPath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); var outputPath = $"{filePathName}.parsed.txt"; var metapath = $"{filePathName}.meta.txt"; var debugPath = $"{filePathName}.debug.txt"; diff --git a/ValidatePlugin.cs b/ValidatePlugin.cs index 8c93b96..984b668 100644 --- a/ValidatePlugin.cs +++ b/ValidatePlugin.cs @@ -71,7 +71,7 @@ public static void Process(ValidateOptions options) //Create a version based on the file size, so that the hash and dict are bound together var fileInfo = new FileInfo(filePath); var fileName = Path.GetFileNameWithoutExtension(filePath); - var filePathName = $"{currentDirectory}\\{fileName}"; + var filePathName = Path.Combine(currentDirectory, fileName); _outputValidPath = $"{filePathName}.valid{fileInfo.Extension}"; _outputInvalidPath = $"{filePathName}.invalid{fileInfo.Extension}";