Ejemplo n.º 1
0
        /// <summary>
        /// Returns the position of the Signature within the stream
        ///  Searches one page from current location starting at the end of the page
        /// </summary>
        /// <param name="reader">A positioned reader</param>
        /// <returns>The position within the stream or -1 if not found</returns>
        public static long FindSignatureInPageBackwards(p4kRecReader reader, byte[] signature)
        {
            long pos = reader.Position;

            byte[] lPage = reader.GetPage( );
            for (int i = lPage.Length - 4; i > 0; i--)
            {
                if (lPage.Skip(i).Take(4).SequenceEqual(signature))
                {
                    // now this should be the start of the item [end of central directory record]
                    return(pos + i);
                }
            }
            return(-1); // not found...
        }
Ejemplo n.º 2
0
        public static readonly byte[] EndOfCentralDirRecord     = { 0x50, 0x4B, 0x05, 0x06 }; // (0x06054b50) 4.3.16  End of central directory record:

        /// <summary>
        /// Returns the position of the Signature within the stream
        ///  Searches one page from current location
        /// </summary>
        /// <param name="reader">A positioned reader</param>
        /// <returns>The position within the stream or -1 if not found</returns>
        public static long FindSignatureInPage(p4kRecReader reader, byte[] signature)
        {
            long pos = reader.Position;

            byte[] lPage = reader.GetPage( );
            for (int i = 0; i < lPage.Length - 4; i++)
            {
                if (lPage.Skip(i).Take(4).SequenceEqual(signature))
                {
                    // now this should be the start of the item
                    return(pos + i);
                }
            }
            return(-1); // not found...
        }