Config: Use Path.Combine() instead of GetAbsolutePath()

This commit is contained in:
2024-01-18 22:07:31 +01:00
parent 7d199282d0
commit 1d1398a9cd
2 changed files with 3 additions and 7 deletions

View File

@ -24,9 +24,9 @@ namespace Elwig.Helpers {
public void Read() { public void Read() {
var config = new ConfigurationBuilder().AddIniFile(FileName).Build(); 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"]; 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"]; Branch = config["general:branch"];
Debug = trueValues.Contains(config["general:debug"]?.ToLower()); Debug = trueValues.Contains(config["general:debug"]?.ToLower());
@ -35,7 +35,7 @@ namespace Elwig.Helpers {
Scales = ScaleList; Scales = ScaleList;
foreach (var s in scales) { foreach (var s in scales) {
string? scaleLog = config[$"scale.{s}:log"]; 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([ ScaleList.Add([
s, config[$"scale.{s}:type"], config[$"scale.{s}:model"], config[$"scale.{s}:connection"], 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 config[$"scale.{s}:empty"], config[$"scale.{s}:filling"], config[$"scale.{s}:limit"], scaleLog

View File

@ -356,9 +356,5 @@ namespace Elwig.Helpers {
} }
return output.OrderByDescending(l => l.Count()); 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;
}
} }
} }