Skip to content

Commit

Permalink
feat: change helper methods to interface ext
Browse files Browse the repository at this point in the history
  • Loading branch information
kalilistic committed Oct 7, 2023
1 parent a941f18 commit 210c72e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
15 changes: 15 additions & 0 deletions Dalamud.DrunkenToad/Extensions/PluginInterfaceExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Dalamud.DrunkenToad.Extensions;

using System;
using System.IO;
using Game.Text.SeStringHandling;
using Plugin;

Expand Down Expand Up @@ -39,4 +41,17 @@ public static string Sanitize(this DalamudPluginInterface value, string str)
/// <param name="str">string to sanitize.</param>
/// <returns>Indicator if player character is valid.</returns>
public static string Sanitize(this DalamudPluginInterface value, Lumina.Text.SeString str) => Sanitize(value, str.ToString());

/// <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 appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var backupsDir = Path.Combine(appDataDir, "XIVLauncher", "pluginBackups", value.InternalName);
Directory.CreateDirectory(backupsDir);
return backupsDir;
}
}
19 changes: 0 additions & 19 deletions Dalamud.DrunkenToad/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
/// </summary>
public static class FileHelper
{
/// <summary>
/// Ensures the existence of specified directories.
/// </summary>
/// <param name="dirPath">The directory path.</param>
/// <param name="subDir">The sub directory.</param>
public static void EnsureDirectoriesExist(string dirPath, string subDir)
{
CreateDirectoryIfNotExists(dirPath);
CreateDirectoryIfNotExists(Path.Combine(dirPath, subDir));
}

/// <summary>
/// Moves the specified file from the source directory to the destination directory and compresses into a zip file.
/// </summary>
Expand Down Expand Up @@ -184,12 +173,4 @@ public static bool VerifyFileAccess(string fileName)
return false;
}
}

private static void CreateDirectoryIfNotExists(string directoryPath)
{
if (!Directory.Exists(directoryPath))
{
Directory.CreateDirectory(directoryPath);
}
}
}

0 comments on commit 210c72e

Please sign in to comment.