mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Plugin Config Directories
Allow plugins to get a directory in the pluginConfig folder
This commit is contained in:
parent
c15340212d
commit
d4f2c5fcac
2 changed files with 20 additions and 0 deletions
|
|
@ -42,6 +42,18 @@ namespace Dalamud.Configuration
|
|||
});
|
||||
}
|
||||
|
||||
public string GetDirectory(string pluginName) {
|
||||
try {
|
||||
var path = GetDirectoryPath(pluginName);
|
||||
if (!path.Exists) {
|
||||
path.Create();
|
||||
}
|
||||
return path.FullName;
|
||||
} catch {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
// Parameterized deserialization
|
||||
// Currently this is called via reflection from DalamudPluginInterface.GetPluginConfig()
|
||||
// Eventually there may be an additional pluginInterface method that can call this directly
|
||||
|
|
@ -59,5 +71,7 @@ namespace Dalamud.Configuration
|
|||
}
|
||||
|
||||
private FileInfo GetPath(string pluginName) => new FileInfo(Path.Combine(this.configDirectory.FullName, $"{pluginName}.json"));
|
||||
private DirectoryInfo GetDirectoryPath(string pluginName) => new DirectoryInfo(Path.Combine(this.configDirectory.FullName, pluginName));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,12 @@ namespace Dalamud.Plugin
|
|||
return this.configs.Load(this.pluginName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the config directory
|
||||
/// </summary>
|
||||
/// <returns>directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName </returns>
|
||||
public string GetPluginConfigDirectory() => this.configs.GetDirectory(this.pluginName);
|
||||
|
||||
#region Chat Links
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue