ReadRange

Document parts, variable data, document editing

Description

Reads a byte range through a TCallbackByteRangeSource into a caller-supplied buffer by forwarding to the read callback

Syntax

Function TCallbackByteRangeSource.ReadRange(StartOffset: Int64;
  Count: Integer; Buffer: PAnsiChar): Integer;

Parameters

StartOffsetZero-based offset of the first byte to read
CountNumber of bytes requested
BufferCaller buffer that receives the requested bytes

Return values

0The request was invalid, the read callback raised an exception or the callback transferred no bytes; GetLastError describes the failure when a message was recorded
PositiveNumber of bytes actually read, never more than the clamped request

Remarks

The request is rejected when no read callback is assigned, Buffer is Nil, Count is zero or negative, StartOffset is negative or StartOffset reaches the total size

A request that extends past the total size is clamped to the remaining bytes instead of being rejected

A callback result below zero is treated as zero, and a result above the clamped count is reduced to the count

The error message recorded for a rejected request or a callback exception is available through GetLastError

See also

GetLastError, IsRangeAvailable, GetTotalSize, GetRangeSupported, LoadFromRangeSource