-
Notifications
You must be signed in to change notification settings - Fork 1
Improve Linux path safety #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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<string, Dictionary<string, int>> | |||||
| //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"); | ||||||
|
||||||
| var path = Path.Combine(options.OutputFolder, "xref", "${options.Prefix}-xref-{de.Key}.tmp"); | |
| var path = Path.Combine(options.OutputFolder, "xref", $"{options.Prefix}-xref-{de.Key}.tmp"); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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; | ||||||
|
||||||
| var pluginFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", name) + Path.DirectorySeparatorChar; | |
| var pluginFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent approach to path construction. String interpolation with Path.DirectorySeparatorChar is used instead of Path.Combine. For consistency with the rest of the PR and proper OS-safe path handling, use Path.Combine(options.OutputFolder, "xref") and add the trailing separator separately if needed, or better yet, avoid the trailing separator altogether if possible.