예제 #1
0
        public void Test001(string archiveName, string entryPath, long length, int hashCode)
        {
            var fileName = Path.Combine(Location, "Media", archiveName);
            var index    = Utils.GetEntryIndex(archiveName, entryPath);

            var entry = default(IntPtr);

            if (!ArchiveEntry.OpenEntry(fileName, index, out entry))
            {
                Assert.Fail("Failed to open entry.");
            }

            try
            {
                Assert.AreEqual(0, ArchiveEntry.GetEntryPosition(entry));
                Assert.AreEqual(length, ArchiveEntry.GetEntryLength(entry));
                Assert.AreEqual(hashCode, Utils.GetEntryHashCode(entry));
                Assert.AreEqual(length, ArchiveEntry.GetEntryPosition(entry));
                Assert.IsTrue(ArchiveEntry.IsEOF(entry));

                //This just checks GetEntryHashCode2 works, it uses ARCHIVE_ReadEntry2.
                Assert.IsTrue(ArchiveEntry.SeekEntry(entry, 0));
                Assert.AreEqual(hashCode, Utils.GetEntryHashCode2(entry));
                Assert.AreEqual(length, ArchiveEntry.GetEntryPosition(entry));
                Assert.IsTrue(ArchiveEntry.IsEOF(entry));
            }
            finally
            {
                ArchiveEntry.CloseEntry(entry);
            }
        }
예제 #2
0
        public void Test005(string archiveName, string entryPath, string password, long length, int hashCode)
        {
            var fileName = Path.Combine(Location, "Media", archiveName);
            var index    = Utils.GetEntryIndex(archiveName, entryPath);

            Utils.PasswordHandler.Set(fileName, password, 5000);

            var entry = default(IntPtr);

            if (!ArchiveEntry.OpenEntry(fileName, index, out entry))
            {
                Assert.Fail("Failed to open entry.");
            }

            try
            {
                Assert.AreEqual(0, ArchiveEntry.GetEntryPosition(entry));
                Assert.AreEqual(length, ArchiveEntry.GetEntryLength(entry));
                Assert.AreEqual(hashCode, Utils.GetEntryHashCode(entry));
                Assert.AreEqual(length, ArchiveEntry.GetEntryPosition(entry));
                Assert.IsTrue(ArchiveEntry.IsEOF(entry));
            }
            finally
            {
                ArchiveEntry.CloseEntry(entry);
            }
        }