38 lines
963 B
C#
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();
|
|
}
|
|
}
|
|
}
|