Config: Use Path.Combine() instead of GetAbsolutePath()
This commit is contained in:
@ -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
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user