/// <summary> /// Create the CKAN directory and any supporting files. /// </summary> private void SetupCkanDirectories(bool scan = true) { log.InfoFormat("Initialising {0}", CkanDir()); // TxFileManager knows if we are in a transaction TxFileManager txFileMgr = new TxFileManager(); if (!Directory.Exists(CkanDir())) { User.RaiseMessage("Setting up CKAN for the first time..."); User.RaiseMessage("Creating {0}", CkanDir()); txFileMgr.CreateDirectory(CkanDir()); if (scan) { User.RaiseMessage("Scanning for installed mods..."); Scan(); } } playTime = TimeLog.Load(TimeLog.GetPath(CkanDir())) ?? new TimeLog(); if (!Directory.Exists(InstallHistoryDir())) { User.RaiseMessage("Creating {0}", InstallHistoryDir()); txFileMgr.CreateDirectory(InstallHistoryDir()); } // Clear any temporary files we find. If the directory // doesn't exist, then no sweat; FilesystemTransaction // will auto-create it as needed. // Create our temporary directories, or clear them if they // already exist. if (Directory.Exists(TempDir())) { var directory = new DirectoryInfo(TempDir()); foreach (FileInfo file in directory.GetFiles()) { txFileMgr.Delete(file.FullName); } foreach (DirectoryInfo subDirectory in directory.GetDirectories()) { txFileMgr.DeleteDirectory(subDirectory.FullName); } } log.InfoFormat("Initialised {0}", CkanDir()); }
/// <summary> /// Initialize the row /// </summary> public PlayTimeRow(string name, GameInstance instance) { Name = name; PlayTime = instance.playTime; path = TimeLog.GetPath(instance.CkanDir()); }