checkIndexHeader

fun checkIndexHeader(in: DataInput, codec: String?, minVersion: Int, maxVersion: Int, expectedID: ByteArray?, expectedSuffix: String?): Int

Reads and validates a header previously written with .writeIndexHeader.

When reading a file, supply the expected codec, expected version range (minVersion to maxVersion), and object ID and suffix.

Return

The actual version found, when a valid header is found that matches codec, with an actual version where minVersion <= actual <= maxVersion, and matching expectedID and expectedSuffix Otherwise an exception is thrown.

Parameters

in

Input stream, positioned at the point where the header was previously written. Typically this is located at the beginning of the file.

codec

The expected codec name.

minVersion

The minimum supported expected version number.

maxVersion

The maximum supported expected version number.

expectedID

The expected object identifier for this file.

expectedSuffix

The expected auxiliary suffix for this file.

See also

.writeIndexHeader

Throws

If the first four bytes are not .CODEC_MAGIC, or if the actual codec found is not codec, or if the expectedID or expectedSuffix do not match.

If the actual version is less than minVersion.

If the actual version is greater than maxVersion * .

IOException

If there is an I/O error reading from the underlying medium.