mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-17 15:00:29 +00:00
First nice version
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user