Example #1
0
        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);
            }
        }
Example #2
0
        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 ParseHeaderNoEmbeddedNameTest()
        {
            PakEntry entry;

            using (var sample = TestHelpers.OpenSample("PakEntry.NoEmbeddedName.dat"))
                using (var br = new EndianBinaryReader(EndianBitConverter.Big, sample)) {
                    entry = PakEntry.ParseHeader(br, null);
                }

            Assert.AreEqual(new QbKey(0xA7F505C4), entry.FileType);
            Assert.AreEqual(0x1000, entry.FileOffset);
            Assert.AreEqual(0xA4, entry.FileLength);
            Assert.AreEqual(new QbKey(0), entry.EmbeddedFilenameKey);
            Assert.AreEqual(new QbKey(0x99360D32), entry.FileFullNameKey);
            Assert.AreEqual(new QbKey(0xF6E6D11A), entry.FileShortNameKey);
            Assert.AreEqual(0, entry.Unknown);
            Assert.AreEqual((PakEntryFlags)0, entry.Flags);
            Assert.IsNull(entry.EmbeddedFilename);
        }
Example #4
0
        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);
            }
        }