From 1d1398a9cd42b7830688c52c47670f44f56fff37 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Thu, 18 Jan 2024 22:07:31 +0100 Subject: [PATCH] Config: Use Path.Combine() instead of GetAbsolutePath() --- Elwig/Helpers/Config.cs | 6 +++--- Elwig/Helpers/Utils.cs | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Elwig/Helpers/Config.cs b/Elwig/Helpers/Config.cs index eaa5f58..8cf601f 100644 --- a/Elwig/Helpers/Config.cs +++ b/Elwig/Helpers/Config.cs @@ -24,9 +24,9 @@ namespace Elwig.Helpers { public void Read() { var config = new ConfigurationBuilder().AddIniFile(FileName).Build(); - DatabaseFile = Utils.GetAbsolutePath(config["database:file"] ?? "database.sqlite3", App.DataPath); + DatabaseFile = Path.Combine(App.DataPath, config["database:file"] ?? "database.sqlite3"); var log = config["database:log"]; - DatabaseLog = log != null ? Utils.GetAbsolutePath(log, App.DataPath) : null; + DatabaseLog = log != null ? Path.Combine(App.DataPath, log) : null; Branch = config["general:branch"]; Debug = trueValues.Contains(config["general:debug"]?.ToLower()); @@ -35,7 +35,7 @@ namespace Elwig.Helpers { Scales = ScaleList; foreach (var s in scales) { string? scaleLog = config[$"scale.{s}:log"]; - if (scaleLog != null) scaleLog = Utils.GetAbsolutePath(scaleLog, App.DataPath); + if (scaleLog != null) scaleLog = Path.Combine(App.DataPath, scaleLog); ScaleList.Add([ s, config[$"scale.{s}:type"], config[$"scale.{s}:model"], config[$"scale.{s}:connection"], config[$"scale.{s}:empty"], config[$"scale.{s}:filling"], config[$"scale.{s}:limit"], scaleLog diff --git a/Elwig/Helpers/Utils.cs b/Elwig/Helpers/Utils.cs index ba8f794..9969a98 100644 --- a/Elwig/Helpers/Utils.cs +++ b/Elwig/Helpers/Utils.cs @@ -356,9 +356,5 @@ namespace Elwig.Helpers { } return output.OrderByDescending(l => l.Count()); } - - public static string GetAbsolutePath(string path, string basePath) { - return (path.Length > 1 && (path[1] == ':' || path[0] == '/' || path[0] == '\\')) ? Path.Combine(basePath, path) : path; - } } }