From ced3d03bdb3ce866d832e03fb212865140905a9a Mon Sep 17 00:00:00 2001 From: Thomas Leyh Date: Sun, 24 Jul 2016 08:14:18 +0200 Subject: Add project files. --- V3/Data/Internal/PathManager.cs | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 V3/Data/Internal/PathManager.cs (limited to 'V3/Data/Internal/PathManager.cs') diff --git a/V3/Data/Internal/PathManager.cs b/V3/Data/Internal/PathManager.cs new file mode 100644 index 0000000..3f4ad9d --- /dev/null +++ b/V3/Data/Internal/PathManager.cs @@ -0,0 +1,51 @@ +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); + } + } + } +} -- cgit v1.2.1