Implement Write() in Config and rename DatabasePath to DatabaseFile
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
@ -7,7 +8,7 @@ namespace Elwig.Helpers {
|
||||
public class Config {
|
||||
|
||||
private readonly string FileName;
|
||||
public string DatabasePath;
|
||||
public string DatabaseFile;
|
||||
|
||||
public Config(string filename) {
|
||||
FileName = filename;
|
||||
@ -21,17 +22,18 @@ namespace Elwig.Helpers {
|
||||
ini = parser.ReadFile(FileName, Encoding.UTF8);
|
||||
} catch {}
|
||||
|
||||
if (ini == null || !ini.TryGetKey("database.path", out string db)) {
|
||||
DatabasePath = App.DataPath + "database.sqlite3";
|
||||
if (ini == null || !ini.TryGetKey("database.file", out string db)) {
|
||||
DatabaseFile = App.DataPath + "database.sqlite3";
|
||||
} else if (db.Length > 1 && db[1] == ':') {
|
||||
DatabasePath = db;
|
||||
DatabaseFile = db;
|
||||
} else {
|
||||
DatabasePath = App.DataPath + db;
|
||||
DatabaseFile = App.DataPath + db;
|
||||
}
|
||||
}
|
||||
|
||||
public void Write() {
|
||||
throw new NotImplementedException();
|
||||
using var file = new StreamWriter(FileName, false, Encoding.UTF8);
|
||||
file.Write($"\n[database]\nfile = {DatabaseFile}\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user