Utility.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. namespace BepInEx.Common
  5. {
  6. /// <summary>
  7. /// Generic helper properties and methods.
  8. /// </summary>
  9. public static class Utility
  10. {
  11. /// <summary>
  12. /// The directory that the Koikatsu .exe is being run from.
  13. /// </summary>
  14. public static string ExecutingDirectory => Path.GetDirectoryName(Environment.CommandLine);
  15. /// <summary>
  16. /// The path that the plugins folder is located.
  17. /// </summary>
  18. public static string PluginsDirectory => Path.Combine(ExecutingDirectory, "BepInEx");
  19. /// <summary>
  20. /// Combines multiple paths together, as the specfic method is not availble in .NET 3.5.
  21. /// </summary>
  22. /// <param name="parts">The multiple paths to combine together.</param>
  23. /// <returns>A combined path.</returns>
  24. public static string CombinePaths(params string[] parts) => parts.Aggregate(Path.Combine);
  25. /// <summary>
  26. /// Converts a file path into a UnityEngine.WWW format.
  27. /// </summary>
  28. /// <param name="path">The file path to convert.</param>
  29. /// <returns>A converted file path.</returns>
  30. public static string ConvertToWWWFormat(string path)
  31. {
  32. return $"file://{path.Replace('\\', '/')}";
  33. }
  34. }
  35. }