/// <summary> /// Loads specified bank file /// </summary> /// <param name="filename"></param> private void _LoadBnk(string filename) { _Bank = new Bnk { Name = filename }; _Bank.Read(); }
/// <summary> /// Opens current entry in file list /// </summary> public void OpenSelectedEntry() { if (fileListView.SelectedItems.Count == 1) { Cursor = Cursors.WaitCursor; ListViewItem currentItem = fileListView.SelectedItems[0]; Object tag = currentItem.Tag; try { if (tag is FileSystemInfo) { // File or directory string path = ((tag as FileSystemInfo).FullName); try { _Refresh(path); CurrentFolder = path; } catch (NotImplementedException ex) { // Not applicable -> entry will be opened with default assos __SystemRun(path); } } else if (tag is PackedFile) { // Packed file -> it must be extracted first // Reloads BNK to get correct contents Bnk parentBnk = new Bnk { Name = CurrentFolder }; parentBnk.Read(); PackedFile updatedPackedFile = parentBnk.GetPackedFile((tag as PackedFile).Id); // TODO handle temporary folder string path = @"T:\COMMUN\" + updatedPackedFile.Name; Bnk.Extract(updatedPackedFile, path); // Opens with default file associations for now __SystemRun(path); } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } finally { Cursor = Cursors.Default; } } }
public void TestBnkAllExtracting() { Bnk bnk1 = _LoadBnk1(); Bnk bnk2 = _LoadBnk2(); Bnk bnk3 = _LoadBnk3(); Context.GameProduct = Context.Product.TDU2; bnk1.Read(); bnk1.ExtractAll(@"E:\Docs\Bureau Vista\California"); bnk2.Read(); bnk2.ExtractAll(@"E:\Docs\Bureau Vista\CCXR"); Context.GameProduct = Context.Product.TDU; bnk3.Read(); bnk3.ExtractAll(@"E:\Docs\Bureau Vista\300_C"); }
public void TestBnkReading() { // TDU2 mode Context.GameProduct = Context.Product.TDU2; Bnk bnk1 = _LoadBnk1(); bnk1.Read(); Assert.IsNotNull(bnk1); // TDU mode Context.GameProduct = Context.Product.TDU; Bnk bnk3 = _LoadBnk3(); bnk3.Read(); Assert.IsNotNull(bnk3); }
/// <summary> /// Recursive method to create file hierarchy on disk /// </summary> /// <param name="packedEntry"></param> /// <param name="lvl"></param> /// <param name="currentPath"></param> private void _ParseTree(PackedFolder packedEntry, int lvl, string currentPath) { if (packedEntry.GetType() == typeof(PackedFile)) { // Extracts file PackedFile pf = packedEntry as PackedFile; if (pf != null) { // Has it been selected ? if (contentsLst.SelectedIndices.Contains((int)pf.Id)) { string targetFilename = (currentPath + @"\" + pf.Name); Bnk.Extract(pf, targetFilename); } } } else { // Creates folder only when starting from interesting level, does not create extension directories if (lvl >= _DIRECTORY_LVL && !packedEntry.Name.StartsWith(".")) { currentPath += (@"\" + packedEntry.Name); if (!Directory.Exists(currentPath)) { Directory.CreateDirectory(currentPath); } } // Children foreach (PackedFolder child in packedEntry.Children) { _ParseTree(child, lvl + 1, currentPath); } } }
/// <summary> /// Methode to redefine to return all entries /// </summary> /// <param name="path"></param> /// <returns></returns> public override List <ListViewItem> GetEntries(string path) { List <ListViewItem> items = new List <ListViewItem>(); // Opens BNK file Bnk bank = new Bnk { Name = path }; bank.Read(); // Reads contents foreach (PackedFile f in bank.PackedFiles) { ListViewItem item = new ListViewItem(f.Name, 4) { Tag = f }; items.Add(item); } return(items); }