private void Modify() { try { var dataPath = "data"; var packagesPath = ModPack.GetPackagePath(); var fileListPath = Path.Combine(ToolFolderName, FileListFileName); var fileNames = Directory.EnumerateFiles(dataPath, "*", SearchOption.AllDirectories).Select(a => ModPack.NormalizePath(a).Replace(ModPack.NormalizePath(dataPath + "/"), "")).ToArray(); if (fileNames == null || !fileNames.Any()) { Trace.WriteLine("Void file name list empty."); return; } foreach (var path in Directory.EnumerateFiles(packagesPath, "*.pack", SearchOption.TopDirectoryOnly).OrderBy(a => a)) { Trace.WriteLine(string.Format("Voiding {0}...", Path.GetFileName(path))); PackVoider.ModifyFileNamesInPack(path, fileNames, true); } Trace.WriteLine("Done voiding file names in pack files, to make client use the files in the data folder."); File.WriteAllLines(fileListPath, fileNames); } catch (IOException ex) { Trace.WriteLine("Error while modifying pack file: " + ex.Message); } catch (Exception ex) { Trace.WriteLine("Error while enabling files: " + ex.GetType().Name + Environment.NewLine + ex); } }
private void RemoveMods() { try { var packagesPath = ModPack.GetPackagePath(); var fileListPath = Path.Combine(ToolFolderName, FileListFileName); string[] fileNames; if (File.Exists(fileListPath)) { fileNames = File.ReadAllLines(fileListPath); } else { fileNames = new string[0]; } if (fileNames == null || !fileNames.Any()) { Trace.WriteLine("Unvoid file name list empty."); return; } foreach (var path in Directory.EnumerateFiles(packagesPath, "*.pack", SearchOption.TopDirectoryOnly).OrderBy(a => a)) { Trace.WriteLine(string.Format("Unvoiding {0}...", Path.GetFileName(path))); PackVoider.ModifyFileNamesInPack(path, fileNames, false); } Trace.WriteLine("Done unvoiding files."); File.WriteAllText(fileListPath, ""); } catch (IOException ex) { Trace.WriteLine("Error while modifying pack file: " + ex.Message); } catch (Exception ex) { Trace.WriteLine("Error while enabling files: " + ex.GetType().Name + Environment.NewLine + ex); } }