public static void RemoveAll(ManagedMods mods) { LogFile.WriteLine("Removing all installed mods"); // Delete bundled archives: DeployArchiveList deployArchives = new DeployArchiveList(mods.GamePath); foreach (DeployArchive deployArchive in deployArchives) { LogFile.WriteLine($" Removing {deployArchive.ArchiveName}"); if (File.Exists(deployArchive.GetArchivePath())) { File.Delete(deployArchive.GetArchivePath()); } mods.Resources.Remove(deployArchive.ArchiveName); } LogFile.WriteLine($" Deleting temporary folders"); deployArchives.DeleteTempFolder(); // Remove mods: foreach (ManagedMod mod in mods) { LogFile.WriteLine($" Removing mod {mod.Title}"); ModDeployment.Remove(mod, mods.Resources, mods.GamePath); } mods.Save(); }
/// <summary> /// Used in the deployment chain to pack each bundled temporary folder to an archive. /// </summary> private static void PackBundledArchives(ResourceList resources, DeployArchiveList archives, bool freezeArchives) { // For each archive... foreach (DeployArchive archive in archives.Reverse()) { // ... if needed ... if (archive.Count > 0 && !Utils.IsDirectoryEmpty(archive.TempPath)) { // ... pack the temporary folder to an archive ... if (freezeArchives) { LogFile.WriteLine($" Freezing archive '{archive.ArchiveName}'"); // either freeze to FrozenData and then copy to Data: Archive2.Create(archive.GetFrozenArchivePath(), archive.TempPath, archive.Compression, archive.Format); if (Configuration.bUseHardlinks) { Utils.CreateHardLink(archive.GetFrozenArchivePath(), archive.GetArchivePath(), true); } else { File.Copy(archive.GetFrozenArchivePath(), archive.GetArchivePath(), true); } } else { LogFile.WriteLine($" Creating archive '{archive.ArchiveName}'"); // or create directly in Data: Archive2.Create(archive.GetArchivePath(), archive.TempPath, archive.Compression, archive.Format); } // ... and add it to the resource list. resources.Insert(0, archive.ArchiveName); } } // Clean up after we're finished. LogFile.WriteLine($" Deleting temporary folder..."); archives.DeleteTempFolder(); }