Paths.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System.IO;
  2. using System.Reflection;
  3. namespace BepInEx
  4. {
  5. /// <summary>
  6. /// Paths used by BepInEx
  7. /// </summary>
  8. public static class Paths
  9. {
  10. public static void SetExecutablePath(string executablePath, string bepinRootPath = null)
  11. {
  12. ExecutablePath = executablePath;
  13. ProcessName = Path.GetFileNameWithoutExtension(executablePath);
  14. GameRootPath = Path.GetDirectoryName(executablePath);
  15. BepInExRootPath = bepinRootPath ?? Path.Combine(GameRootPath, "BepInEx");
  16. ConfigPath = Path.Combine(BepInExRootPath, "config");
  17. BepInExConfigPath = Path.Combine(ConfigPath, "BepInEx.cfg");
  18. PluginPath = Path.Combine(BepInExRootPath, "plugins");
  19. PatcherPluginPath = Path.Combine(BepInExRootPath, "patchers");
  20. BepInExAssemblyDirectory = Path.Combine(BepInExRootPath, "core");
  21. BepInExAssemblyPath = Path.Combine(BepInExAssemblyDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.dll");
  22. CachePath = Path.Combine(BepInExRootPath, "cache");
  23. }
  24. internal static void SetPluginPath(string pluginPath)
  25. {
  26. PluginPath = Utility.CombinePaths(BepInExRootPath, pluginPath);
  27. }
  28. /// <summary>
  29. /// The directory that the core BepInEx DLLs reside in.
  30. /// </summary>
  31. public static string BepInExAssemblyDirectory { get; private set; }
  32. /// <summary>
  33. /// The path to the core BepInEx DLL.
  34. /// </summary>
  35. public static string BepInExAssemblyPath { get; private set; }
  36. /// <summary>
  37. /// The path to the main BepInEx folder.
  38. /// </summary>
  39. public static string BepInExRootPath { get; private set; }
  40. /// <summary>
  41. /// The path of the currently executing program BepInEx is encapsulated in.
  42. /// </summary>
  43. public static string ExecutablePath { get; private set; }
  44. /// <summary>
  45. /// The directory that the currently executing process resides in.
  46. /// </summary>
  47. public static string GameRootPath { get; private set; }
  48. /// <summary>
  49. /// The path to the config directory.
  50. /// </summary>
  51. public static string ConfigPath { get; private set; }
  52. /// <summary>
  53. /// The path to the global BepInEx configuration file.
  54. /// </summary>
  55. public static string BepInExConfigPath { get; private set; }
  56. /// <summary>
  57. /// The path to temporary cache files.
  58. /// </summary>
  59. public static string CachePath { get; private set; }
  60. /// <summary>
  61. /// The path to the patcher plugin folder which resides in the BepInEx folder.
  62. /// </summary>
  63. public static string PatcherPluginPath { get; private set; }
  64. /// <summary>
  65. /// The path to the plugin folder which resides in the BepInEx folder.
  66. /// <para>
  67. /// This is ONLY guaranteed to be set correctly when Chainloader has been initialized.
  68. /// </para>
  69. /// </summary>
  70. public static string PluginPath { get; private set; }
  71. /// <summary>
  72. /// The name of the currently executing process.
  73. /// </summary>
  74. public static string ProcessName { get; private set; }
  75. }
  76. }