/// <summary> /// Wrap creating a diffdat for a given old and new dat /// </summary> /// <param name="outdat">Output file</param> /// <param name="old">Old DAT file</param> /// <param name="newdat">New DAT file</param> /// <param name="name">Name value in DAT header</param> /// <param name="description">Description value in DAT header</param> private static void InitDiffDat( string outdat, string old, string newdat, string name, string description) { // Ensure the output directory Utilities.EnsureOutputDirectory(outdat, create: true); // Check that all required files exist if (!File.Exists(old)) { Globals.Logger.Error("File '{0}' does not exist!", old); return; } if (!File.Exists(newdat)) { Globals.Logger.Error("File '{0}' does not exist!", newdat); return; } // Create the encapsulating datfile DatFile datfile = new DatFile() { Name = name, Description = description, }; // Create the inputs List <string> dats = new List <string>(); dats.Add(newdat); List <string> basedats = new List <string>(); basedats.Add(old); // Now run the diff on the inputs datfile.DetermineUpdateType(dats, basedats, outdat, UpdateMode.DiffAgainst, false /* inplace */, false /* skip */, false /* clean */, false /* remUnicode */, false /* descAsName */, new Filter(), SplitType.None, ReplaceMode.None, false /* onlySame */); }
/// <summary> /// Wrap converting and updating DAT file from any format to any format /// </summary> /// <param name="inputPaths">List of input filenames</param> /// <param name="basePaths">List of base filenames</param> /// /* Normal DAT header info */ /// <param name="datHeader">All DatHeader info to be used</param> /// /* Merging and Diffing info */ /// <param name="updateMode">Non-zero flag for diffing mode, zero otherwise</param> /// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param> /// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param> /// <param name="bare">True if the date should not be appended to the default name, false otherwise</param> /// /* Filtering info */ /// <param name="filter">Pre-populated filter object for DAT filtering</param> /// <param name="splitType">Type of the split that should be performed (split, merged, fully merged)</param> /// /* Output DAT info */ /// <param name="outDir">Optional param for output directory</param> /// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param> /// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param> /// <param name="descAsName">True if descriptions should be used as names, false otherwise (default)</param> /// <param name="replaceMode">ReplaceMode representing what should be updated [only for base replacement]</param> /// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise [only for base replacement]</param> private static void InitUpdate( List <string> inputPaths, List <string> basePaths, /* Normal DAT header info */ DatHeader datHeader, /* Merging and Diffing info */ UpdateMode updateMode, bool inplace, bool skip, bool bare, /* Filtering info */ Filter filter, SplitType splitType, /* Output DAT info */ string outDir, bool clean, bool remUnicode, bool descAsName, ReplaceMode replaceMode, bool onlySame) { // Normalize the extensions datHeader.AddExtension = (String.IsNullOrWhiteSpace(datHeader.AddExtension) || datHeader.AddExtension.StartsWith(".") ? datHeader.AddExtension : "." + datHeader.AddExtension); datHeader.ReplaceExtension = (String.IsNullOrWhiteSpace(datHeader.ReplaceExtension) || datHeader.ReplaceExtension.StartsWith(".") ? datHeader.ReplaceExtension : "." + datHeader.ReplaceExtension); // If we're in a special update mode and the names aren't set, set defaults if (updateMode != 0) { // Get the values that will be used if (String.IsNullOrWhiteSpace(datHeader.Date)) { datHeader.Date = DateTime.Now.ToString("yyyy-MM-dd"); } if (String.IsNullOrWhiteSpace(datHeader.Name)) { datHeader.Name = (updateMode != 0 ? "DiffDAT" : "MergeDAT") + (datHeader.Type == "SuperDAT" ? "-SuperDAT" : "") + (datHeader.DedupeRoms != DedupeType.None ? "-deduped" : ""); } if (String.IsNullOrWhiteSpace(datHeader.Description)) { datHeader.Description = (updateMode != 0 ? "DiffDAT" : "MergeDAT") + (datHeader.Type == "SuperDAT" ? "-SuperDAT" : "") + (datHeader.DedupeRoms != DedupeType.None ? " - deduped" : ""); if (!bare) { datHeader.Description += " (" + datHeader.Date + ")"; } } if (String.IsNullOrWhiteSpace(datHeader.Category) && updateMode != 0) { datHeader.Category = "DiffDAT"; } if (String.IsNullOrWhiteSpace(datHeader.Author)) { datHeader.Author = "SabreTools"; } } // If no replacement mode is set, default to Names if (replaceMode == ReplaceMode.None) { replaceMode = ReplaceMode.ItemName; } // Populate the DatData object DatFile userInputDat = new DatFile(datHeader); userInputDat.DetermineUpdateType(inputPaths, basePaths, outDir, updateMode, inplace, skip, clean, remUnicode, descAsName, filter, splitType, replaceMode, onlySame); }