ICSharpCode.SharpZipLib.Zip.ZipHelperStream.LocateBlockWithSignature C# (CSharp) Method

LocateBlockWithSignature() public method

Locates a block with the desired signature.
public LocateBlockWithSignature ( int signature, long endLocation, int minimumBlockSize, int maximumVariableData ) : long
signature int The signature to find.
endLocation long Location, marking the end of block.
minimumBlockSize int Minimum size of the block.
maximumVariableData int The maximum variable data.
return long
        public long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData)
        {
            long pos = endLocation - minimumBlockSize;
            if (pos < 0) {
                return -1;
            }

            long giveUpMarker = Math.Max(pos - maximumVariableData, 0);

            // TODO: This loop could be optimised for speed.
            do {
                if (pos < giveUpMarker) {
                    return -1;
                }
                Seek(pos--, SeekOrigin.Begin);
            } while (ReadLEInt() != signature);

            return Position;
        }

Usage Example

Esempio n. 1
0
		// NOTE this returns the offset of the first byte after the signature.
		long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData)
		{
			using ( ZipHelperStream les = new ZipHelperStream(baseStream_) ) {
				return les.LocateBlockWithSignature(signature, endLocation, minimumBlockSize, maximumVariableData);
			}
		}
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipHelperStream::LocateBlockWithSignature