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 override long Seek(long offset, SeekOrigin origin) { switch (origin) { case SeekOrigin.Begin: break; case SeekOrigin.Current: offset = this.Position + offset; break; case SeekOrigin.End: offset = this.Length + offset; break; } if (!ArchiveEntry.SeekEntry(this.Entry, offset)) { return(0); } return(offset); }
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); } }