public void PakEntryTestSetUp() { this.smallArchiveStream = TestHelpers.CreateTempCopy("PakArchive.SmallNoPab.pak.xen"); this.largeArchiveStream = TestHelpers.CreateTempCopy("PakArchive.LargeNoPab.pak.xen"); this.smallArchive = new PakArchive(this.smallArchiveStream); this.largeArchive = new PakArchive(this.largeArchiveStream); }
public void CreateEntryLargeWithPabTest() { using (PakArchive archive = new PakArchive(this.largeWithPabPakStream, this.largeWithPabPabStream)) { archive.CreateEntry(@"test\new\entry.txt"); Assert.AreEqual(128, archive.Entries.Count); Assert.AreEqual(0x2000, archive.Entries[0].FileOffset); Assert.AreEqual(0x6DC60, archive.Entries.Last().FileOffsetRelative); Assert.AreEqual(0xFE0, archive.Entries.Last().HeaderOffset); PakEntry entry; this.largeWithPabPakStream.Position = 0xFE0; entry = PakEntry.ParseHeader( new EndianBinaryReader(EndianBitConverter.Big, this.largeWithPabPakStream), null); Assert.AreEqual(new QbKey(".txt"), entry.FileType); Assert.AreEqual(0x6DC60, entry.FileOffsetRelative); Assert.AreEqual(new QbKey(@"test\new\entry.txt"), entry.FileFullNameKey); this.largeWithPabPakStream.Position = 0x1000; entry = PakEntry.ParseHeader( new EndianBinaryReader(EndianBitConverter.Big, this.largeWithPabPakStream), null); Assert.AreEqual(new QbKey(".last"), entry.FileType); Assert.AreEqual(0x6DC40, entry.FileOffsetRelative); Assert.AreEqual(0x2000, this.largeWithPabPakStream.Length); } }
public void CreateEntrySmallNoPabTest() { using (PakArchive archive = new PakArchive(this.smallNoPabStream)) { archive.CreateEntry(@"test\new\entry.txt"); Assert.AreEqual(4, archive.Entries.Count); Assert.AreEqual(0x1000, archive.Entries[0].FileOffset); Assert.AreEqual(0x13A760, archive.Entries[3].FileOffsetRelative); Assert.AreEqual(0x60, archive.Entries[3].HeaderOffset); PakEntry entry; this.smallNoPabStream.Position = 0x60; entry = PakEntry.ParseHeader( new EndianBinaryReader(EndianBitConverter.Big, this.smallNoPabStream), null); Assert.AreEqual(new QbKey(".txt"), entry.FileType); Assert.AreEqual(0x13A760, entry.FileOffsetRelative); Assert.AreEqual(new QbKey(@"test\new\entry.txt"), entry.FileFullNameKey); this.smallNoPabStream.Position = 0x80; entry = PakEntry.ParseHeader( new EndianBinaryReader(EndianBitConverter.Big, this.smallNoPabStream), null); Assert.AreEqual(new QbKey(".last"), entry.FileType); Assert.AreEqual(0x13A740, entry.FileOffsetRelative); } }
public void PakArchiveWithPabTest() { using (PakArchive archive = new PakArchive(this.smallWithPabPakStream, this.smallWithPabPabStream)) { Assert.AreEqual(3, archive.Entries.Count); Assert.AreEqual(0x1000, archive.Entries[0].FileOffset); Assert.AreEqual(0x2000, archive.Entries[1].FileOffset); Assert.AreEqual(0x1113A0, archive.Entries[2].FileOffset); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { var dialogResult = this.openFileDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { var oldArchive = this.openArchive; this.openArchive = PakFile.Open(this.openFileDialog.FileName); oldArchive?.Dispose(); populateListView(); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { var dialogResult = this.openFileDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { var oldArchive = this.openArchive; try { this.openArchive = PakFile.Open(this.openFileDialog.FileName); } catch (UnauthorizedAccessException ex) { MessageBox.Show(@"Please run as administrator!"); } oldArchive?.Dispose(); populateListView(); } }
public void CreateEntryLargeNoPabTest() { using (PakArchive archive = new PakArchive(this.largeNoPabStream)) { archive.CreateEntry(@"test\new\entry.txt"); Assert.AreEqual(128, archive.Entries.Count); Assert.AreEqual(0x2000, archive.Entries[0].FileOffset); Assert.AreEqual(0x6DC60, archive.Entries.Last().FileOffsetRelative); Assert.AreEqual(0xFE0, archive.Entries.Last().HeaderOffset); PakEntry entry; this.largeNoPabStream.Position = 0xFE0; entry = PakEntry.ParseHeader( new EndianBinaryReader(EndianBitConverter.Big, this.largeNoPabStream), null); Assert.AreEqual(new QbKey(".txt"), entry.FileType); Assert.AreEqual(0x6DC60, entry.FileOffsetRelative); Assert.AreEqual(new QbKey(@"test\new\entry.txt"), entry.FileFullNameKey); this.largeNoPabStream.Position = 0x1000; entry = PakEntry.ParseHeader( new EndianBinaryReader(EndianBitConverter.Big, this.largeNoPabStream), null); Assert.AreEqual(new QbKey(".last"), entry.FileType); Assert.AreEqual(0x6DC40, entry.FileOffsetRelative); this.largeNoPabStream.Position = 0x2000; var bytes = new byte[0x20]; var expected = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB4, 0x1C, 0x08, 0x02, 0x04, 0x10, 0x04, 0x08, 0x0C, 0x0C, 0x08, 0x02, 0x04, 0x14, 0x02, 0x04, 0x0C, 0x10, 0x10, 0x0C, 0x00, 0x00, 0x20, 0x07, 0x00 }; this.largeNoPabStream.Read(bytes, 0, 0x20); Assert.AreEqual(expected, bytes); } }
public override bool LoadRes() { FileLocation fl = ResourceLocation as FileLocation; if (fl != null) { arc = new PakArchive(fl); entries = arc.GetEntries(); ListView.ListViewItemCollection col = listView1.Items; for (int i = 0; i < entries.Length; i++) { ListViewItem item = col.Add(entries[i].Name); item.SubItems.Add(entries[i].Size.ToString()); item.SubItems.Add(entries[i].Offset.ToString()); item.SubItems.Add(entries[i].Flag.ToString()); } } return true; }
public override bool LoadRes() { FileLocation fl = ResourceLocation as FileLocation; if (fl != null) { arc = new PakArchive(fl); entries = arc.GetEntries(); ListView.ListViewItemCollection col = listView1.Items; for (int i = 0; i < entries.Length; i++) { ListViewItem item = col.Add(entries[i].Name); item.SubItems.Add(entries[i].Size.ToString()); item.SubItems.Add(entries[i].Offset.ToString()); item.SubItems.Add(entries[i].Flag.ToString()); } } return(true); }
public override void OnImportAsset(AssetImportContext context) { GitIgnore.Ignore = context.assetPath; byte[] pak = File.ReadAllBytes(context.assetPath).pizg(); PakArchive.ParseHexen2PakFile(pak, file => { // compute the path where we'll store this string path = context.assetPath.replaceAll("/[^/]+$", "/_pak/") + file._name; // ignore this file (but we should be keeping the .meta) GitIgnore.Ignore = path; // create any parent directories Directory.CreateDirectory(path.flip().drop(c => c != '/').flip()); // dump the file itself File.WriteAllBytes(path, file.read(pak)); // tell Unity to import the file AssetDatabase.ImportAsset(path); }); }