First nice version

This commit is contained in:
JustArchi
2016-03-20 08:29:27 +01:00
parent b642f4b240
commit f77cb6d33b
9 changed files with 242 additions and 83 deletions

View File

@@ -13,8 +13,9 @@ namespace ConfigGenerator {
ASFConfigs.Add(this);
}
protected ASFConfig(string filePath) : base() {
protected ASFConfig(string filePath) {
FilePath = filePath;
ASFConfigs.Add(this);
}
internal virtual void Save() {
@@ -26,5 +27,37 @@ namespace ConfigGenerator {
}
}
}
internal virtual void Remove() {
string queryPath = Path.GetFileNameWithoutExtension(FilePath);
lock (FilePath) {
foreach (var configFile in Directory.EnumerateFiles(Program.ConfigDirectory, queryPath + ".*")) {
try {
File.Delete(configFile);
} catch (Exception e) {
Logging.LogGenericException(e);
}
}
}
ASFConfigs.Remove(this);
}
internal virtual void Rename(string botName) {
if (string.IsNullOrEmpty(botName)) {
return;
}
string queryPath = Path.GetFileNameWithoutExtension(FilePath);
lock (FilePath) {
foreach (var file in Directory.EnumerateFiles(Program.ConfigDirectory, queryPath + ".*")) {
try {
File.Move(file, Path.Combine(Program.ConfigDirectory, botName + Path.GetExtension(file)));
} catch (Exception e) {
Logging.LogGenericException(e);
}
}
FilePath = Path.Combine(Program.ConfigDirectory, botName + ".json");
}
}
}
}