/// <summary> /// Prepares a packed file for viewing/editing. can be used as stand-alone to get files without creating any task. /// </summary> /// <param name="bnk">BNK file</param> /// <param name="packedFilePath">Path of packed file to prepare</param> /// <returns>Full path of extracted file</returns> public string PrepareFile(BNK bnk, string packedFilePath) { string returnPath = null; if (bnk == null || string.IsNullOrEmpty(packedFilePath)) { return(returnPath); } // Working folder string workFolder = File2.SetTemporaryFolder(null, LibraryConstants.FOLDER_TEMP, true); if (workFolder == null) { throw new Exception(ERROR_CODE_TEMP_FOLDER); } // Extracting packed file into working folder string packedFileName = bnk.GetPackedFileName(packedFilePath); returnPath = string.Format(@"{0}\{1}", workFolder, packedFileName); bnk.ExtractPackedFile(packedFilePath, returnPath, false); // Removing attributes on file File.SetAttributes(returnPath, FileAttributes.Normal); return(returnPath); }
/// <summary> /// Réalise la conversion multiple /// </summary> private void _MultipleConvert() { // Vérifications if (string.IsNullOrEmpty(sourceBNKTextBox.Text) || string.IsNullOrEmpty(targetFolderTextBox.Text)) { return; } Cursor = Cursors.WaitCursor; // Parcours des fichiers et extraction des 2DB BNK bnkFile = TduFile.GetFile(sourceBNKTextBox.Text) as BNK; if (bnkFile == null) { throw new Exception(_ERROR_INVALID_BNK_FILE); } Collection <string> textureFiles = bnkFile.GetPackedFilesPathsByExtension(LibraryConstants.EXTENSION_2DB_FILE); string tempFolder = File2.SetTemporaryFolder(null, LibraryConstants.FOLDER_TEMP, true); foreach (string anotherFilePath in textureFiles) { // 1.Extraction depuis le BNK vers le dossier temporaire bnkFile.ExtractPackedFile(anotherFilePath, tempFolder, true); // 2.Conversion des fichiers 2DB>DDS string fileName = tempFolder + @"\" + bnkFile.GetPackedFileName(anotherFilePath); FileInfo fi = new FileInfo(fileName); string newFileName = targetFolderTextBox.Text + @"\" + File2.ChangeExtensionOfFilename(fi.Name, LibraryConstants.EXTENSION_DDS_FILE); // If file already exists, it is renamed Tools.RenameIfNecessary(newFileName, LibraryConstants.SUFFIX_OLD_FILE); GraphicsConverters._2DBToDDS(fileName, newFileName); } // EVO 32 string message = string.Format(_STATUS_SUCCESS_MULTIPLE, textureFiles.Count); StatusBarLogManager.ShowEvent(this, message); // On efface le champ source sourceBNKTextBox.Text = ""; // Mise à jour de l'emplacement des 2DB _2DBLocationLink.Text = tempFolder; Cursor = Cursors.Default; }
static BankInfoOutputObject GetBankInfoOutput(BNK bankFile) { var outputObject = new BankInfoOutputObject((int)bankFile.Size, (int)bankFile.Year); var packedFilesInformations = new List <PackedFileInfoOutputObject>(); foreach (var packedFilePath in bankFile.GetPackedFilesPaths(null)) { var packedFileShortName = bankFile.GetPackedFileName(packedFilePath); var packedFileSize = bankFile.GetPackedFileSize(packedFilePath); var packedFileTypeDescription = bankFile.GetPackedFileTypeDescription(packedFilePath); var packedFilesInfo = new PackedFileInfoOutputObject(packedFileShortName, packedFilePath, packedFileSize, packedFileTypeDescription); packedFilesInformations.Add(packedFilesInfo); } outputObject.PackedFiles.AddRange(packedFilesInformations); return(outputObject); }