/// <summary> /// Actually run the App. /// </summary> /// <param name="args"></param> static void Main(string[] args) { if (args.Length < 2) { Help(); System.Environment.Exit(0); } string folder = args[0]; string mpqPath = args[1]; if (!Directory.Exists(folder)) { Logger.Danger("Could not find specified folder '" + folder + "'. Please ensure this exists!"); System.Environment.Exit(0); } string[] files = Directory.GetFiles(folder, "*", SearchOption.AllDirectories); int total = files.Length; Logger.Info(String.Format("Writing ({0}) files from '{1}' to '{2}'...\n", total, folder, mpqPath)); if (File.Exists(mpqPath)) { File.Delete(mpqPath); } ProgressBar progress = new ProgressBar(60); int current = 1; using (MpqArchive mpq = MpqArchive.CreateNew(mpqPath, MpqArchiveVersion.Version2, MpqFileStreamAttributes.None, MpqFileStreamAttributes.CreateAttributesFile, files.Length)) { foreach (string file in files) { string innerPath = After(file, folder); innerPath = innerPath.Substring(1); // Get rid of leading slash. mpq.AddFileFromDiskWithCompression(file, innerPath, MpqCompressionTypeFlags.MPQ_COMPRESSION_ZLIB); int percentage = (current / total) * 100; progress.Update(percentage); current++; } } Logger.Success("\n\nDone!\n"); }
static void Main(string[] args) { //Try to load configuration file Config = new ApplicationConfigurationLoader().BuildConfigFile(); //Now we want to search the entire output directory //for DBC files and stick them in the MPQ. string[] dbcFileNames = Directory.GetFiles(Config.DbcOutputPath); //Creates an MPQ with length of dbc files at the MPQ output directory. using (MpqArchive mpq = MpqArchive.CreateNew(Path.Combine(Config.MpqOutputPath, $"{Config.MpqOutputName}.MPQ"), MpqArchiveVersion.Version2, MpqFileStreamAttributes.None, MpqFileStreamAttributes.None, dbcFileNames.Length)) { foreach (string dbc in dbcFileNames) { mpq.AddFileFromDiskWithCompression(dbc, Path.Combine("DBClientFiles", Path.GetFileName(dbc)), MpqCompressionTypeFlags.MPQ_COMPRESSION_ZLIB); } } }
static void Main(string[] args) { Console.WriteLine(DBCToolsExtensions.BuildToolsWelcomeMessage("CreateMPQ")); //Try to load configuration file Config = new ApplicationConfigurationLoader().BuildConfigFile(); //Now we want to search the entire output directory //for DBC files and stick them in the MPQ. string[] dbcFileNames = Directory.GetFiles(Config.DbcOutputPath); if (!Directory.Exists(Config.MpqOutputPath)) { Directory.CreateDirectory(Config.MpqOutputPath); } string fullFilePath = Path.Combine(Config.MpqOutputPath, $"{Config.MpqOutputName}.MPQ"); //If the MPQ already exists, then delete it if (File.Exists(fullFilePath)) { File.Delete(fullFilePath); } //Creates an MPQ with length of dbc files at the MPQ output directory. using (MpqArchive mpq = MpqArchive.CreateNew(fullFilePath, MpqArchiveVersion.Version2, MpqFileStreamAttributes.None, MpqFileStreamAttributes.CreateAttributesFile, dbcFileNames.Length)) { foreach (string dbc in dbcFileNames) { mpq.AddFileFromDiskWithCompression(dbc, Path.Combine("DBFilesClient", Path.GetFileName(dbc)), MpqCompressionTypeFlags.MPQ_COMPRESSION_ZLIB); } } Console.WriteLine("Finished. Press any key!"); }