using System; using System.IO; namespace V3.Data.Internal { /// /// Default implementation of IPathManager. /// // ReSharper disable once ClassNeverInstantiated.Global internal sealed class PathManager : IPathManager { /// /// The base directory for persistent application data. /// public string AppDirectory { get; } /// /// The file to store the options in. /// public string OptionsFile { get; } /// /// The directory for save games. /// public string SaveGameDirectory { get; } /// /// Creates a new path manager and initializes the paths, but does not /// create the directories if they don’t already exist. /// public PathManager() { var localAppDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); AppDirectory = $"{localAppDir}/V3"; SaveGameDirectory = $"{AppDirectory}/SaveGames"; OptionsFile = $"{AppDirectory}/Options.xml"; } /// /// Creates the application directories that do not already exist. /// public void CreateMissingDirectories() { string[] directories = { AppDirectory, SaveGameDirectory }; foreach (var directory in directories) { if (!Directory.Exists(directory)) Directory.CreateDirectory(directory); } } } }