Files
elwig/Elwig/Helpers/Config.cs
2023-04-15 21:31:09 +02:00

38 lines
963 B
C#

using System;
using System.Text;
using IniParser;
using IniParser.Model;
namespace Elwig.Helpers {
public class Config {
private readonly string FileName;
public string DatabasePath;
public Config(string filename) {
FileName = filename;
Read();
}
public void Read() {
var parser = new FileIniDataParser();
IniData? ini = null;
try {
ini = parser.ReadFile(FileName, Encoding.UTF8);
} catch {}
if (ini == null || !ini.TryGetKey("database.path", out string db)) {
DatabasePath = App.DataPath + "database.sqlite3";
} else if (db.Length > 1 && db[1] == ':') {
DatabasePath = db;
} else {
DatabasePath = App.DataPath + db;
}
}
public void Write() {
throw new NotImplementedException();
}
}
}