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
StartOffset | Zero-based offset of the first byte to read |
|---|---|
Count | Number of bytes requested |
Buffer | Caller buffer that receives the requested bytes |
Return values
0 | The request was invalid, the read callback raised an exception or the callback transferred no bytes; GetLastError describes the failure when a message was recorded |
|---|---|
| Positive | Number 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