using SRML.Utils; using System; using System.IO; using BepInEx; namespace SRML { public static class FileSystem { public const String DataPath = "SlimeRancher_Data"; public static String ModPath = "SRML/Mods"; public static String LibPath = "SRML/Libs"; /// /// Checks if a path exists and creates it if it doesn't /// /// Path to be checked /// returns the original path argument public static string CheckDirectory(string path) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return path; } /// /// When called from a mod, gets the base path of that mod /// /// The base path of the current executing mod public static String GetMyPath() { var assembly = ReflectionUtils.GetRelevantAssembly(); return SRModLoader.GetModForAssembly(assembly)?.Path ?? Path.GetDirectoryName(assembly.Location); } /// /// Gets a mods config path /// /// The mod whose config path is needed /// The config path internal static String GetConfigPath(SRMod mod) { return CheckDirectory(Path.Combine(Path.Combine(Paths.GameRootPath, "SRML/Config"), mod?.ModInfo.Id ?? "SRML")); } /// /// Gets the current mods config path /// /// The config path public static String GetMyConfigPath() { return GetConfigPath(SRMod.GetCurrentMod()); } } }