public void Test007(string archiveName, string password) { var fileName = Path.Combine(Location, "Media", archiveName); var count = Utils.GetEntryCount(fileName); Utils.PasswordHandler.Set(fileName, password, 5000); Utils.ParallelIterations(a => { var entry = default(IntPtr); var isFile = default(bool); Utils.GetEntryType(archiveName, a, out isFile); var isOpen = ArchiveEntry.OpenEntry(fileName, a, out entry); Assert.AreEqual(isFile, isOpen); try { if (isFile) { Utils.GetEntryHashCode(entry); Assert.IsTrue(ArchiveEntry.IsEOF(entry)); } } finally { ArchiveEntry.CloseEntry(entry); } }, count); }
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); } }
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); } }
public void Test003(string archiveName, int iterations) { var fileName = Path.Combine(Location, "Media", archiveName); var count = Utils.GetEntryCount(fileName); Utils.Iterations(a => { for (var b = 0; b < count; b++) { var entry = default(IntPtr); if (!ArchiveEntry.OpenEntry(fileName, b, out entry)) { Assert.Fail("Failed to open entry."); } try { Utils.GetEntryHashCode(entry); Assert.IsTrue(ArchiveEntry.IsEOF(entry)); } finally { ArchiveEntry.CloseEntry(entry); } } }, iterations); }
public void Close() { if (this.ReadStream != null) { this.ReadStream.Dispose(); this.ReadStream = null; } if (!IntPtr.Zero.Equals(this.Entry)) { ArchiveEntry.CloseEntry(this.Entry); this.Entry = IntPtr.Zero; } this.IsOpen = false; }
public void Test006(string archiveName, string entryPath, string password) { if (!this.Cleanup) { Assert.Ignore("Requires clean state."); } var fileName = Path.Combine(Location, "Media", archiveName); var index = Utils.GetEntryIndex(archiveName, entryPath); if (string.IsNullOrEmpty(password)) { Utils.PasswordHandler.Reset(); } else { 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(0, Utils.GetEntryHashCode(entry)); Assert.AreEqual(ArchiveEntry.RESULT_PASSWORD_REQUIRED, Utils.GetEntryResult(entry)); } finally { ArchiveEntry.CloseEntry(entry); } }
public void Test002(string archiveName, string entryPath, long length) { 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.IsTrue(ArchiveEntry.SeekEntry(entry, length)); Assert.AreEqual(length, ArchiveEntry.GetEntryPosition(entry)); Assert.IsTrue(ArchiveEntry.IsEOF(entry)); } finally { ArchiveEntry.CloseEntry(entry); } }
public void Test004(string archiveName) { var fileName = Path.Combine(Location, "Media", archiveName); var count = Utils.GetEntryCount(fileName); for (var a = 0; a < count; a++) { var entry = default(IntPtr); if (!ArchiveEntry.OpenEntry(fileName, a, out entry)) { Assert.Fail("Failed to open entry."); } try { var buffer = new byte[10240]; Assert.Greater(ArchiveEntry.ReadEntry(entry, buffer, buffer.Length), 0); } finally { ArchiveEntry.CloseEntry(entry); } } }