Skip to content

Commit

Permalink
fix: make backups WINE friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
kalilistic committed Oct 16, 2023
1 parent a2a8d84 commit 89be417
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Dalamud.DrunkenToad/Extensions/PluginInterfaceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,37 @@ public static string Sanitize(this DalamudPluginInterface value, string str)
public static string Sanitize(this DalamudPluginInterface value, Lumina.Text.SeString str) => Sanitize(value, str.ToString());

/// <summary>
/// Get the plugin backup directory.
/// Get the plugin backup directory for windows (don't use for Wine).
/// </summary>
/// <param name="value">dalamud plugin interface.</param>
/// <returns>Plugin backup directory.</returns>
public static string PluginBackupDirectory(this DalamudPluginInterface value)
public static string WindowsPluginBackupDirectory(this DalamudPluginInterface value)
{
var appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var backupsDir = Path.Combine(appDataDir, "XIVLauncher", $"{value.InternalName.FirstCharToLower()}Backups");
Directory.CreateDirectory(backupsDir);
return backupsDir;
}

/// <summary>
/// Get the plugin backup directory.
/// </summary>
/// <param name="value">dalamud plugin interface.</param>
/// <returns>Plugin backup directory.</returns>
public static string PluginBackupDirectory(this DalamudPluginInterface value)
{
var configDir = value.ConfigDirectory.Parent;
var appDir = configDir?.Parent;
if (appDir == null)
{
return WindowsPluginBackupDirectory(value); // use as a fallback
}

var backupsDir = Path.Combine(appDir.FullName, $"{value.InternalName.FirstCharToLower()}Backups");
Directory.CreateDirectory(backupsDir);
return backupsDir;
}

/// <summary>
/// Check if different version of plugin is loaded.
/// </summary>
Expand Down

0 comments on commit 89be417

Please sign in to comment.