MyFSD_ReadFileScatter (Windows CE 5.0)

Send Feedback

The ReadFileScatter function reads data from a file and stores it in an array of buffers.

BOOL ReadFileScatter(
  HANDLEhFile,
  FILE_SEGMENT_ELEMENTaSegmentArray,
  DWORDnNumberOfBytesToRead,
  LPDWORDlpReserved,
  LPOVERLAPPEDlpOverlapped
);

Parameters

  • hFile
    [in] Handle to the file to be read.

    This file handle must have been created with the GENERIC_READ right.

  • aSegmentArray
    [out] Pointer to an array of FILE_SEGMENT_ELEMENT buffers that receives the data. Each element can receive one page of data. To determine the size of a system page, use GetSystemInfo.

  • nNumberOfBytesToRead
    [in] Total number of bytes to be read from the file. Each element of aSegmentArray contains a one-page chunk of this total.

  • lpReserved
    [in] Pointer to an array of FILE_SEGMENT_ELEMENT unions that enables reading from discontinuous parts of the file by providing offsets to read from. If used, this parameter must contain the same number of elements as the aSegmentArray, because there is a one-to-one mapping between the array of offsets and the aSegmentArray such that a particular offset corresponds to the buffer to read into.

    If this parameter contains NULL, then the read will start at the internal file pointer and read contiguous pages. In this case, the function updates the internal file pointer after the read is complete.

  • lpOverlapped
    [in] Unsupported; set to NULL.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call the GetLastError function.

If the function attempts to read past the end of the file, the function returns zero, and GetLastError returns ERROR_HANDLE_EOF.

Remarks

The array pointed to by aSegmentArray must contain enough elements to store nNumberOfBytesToWrite bytes of data, plus one element for the terminating NULL.

For example, if there are 40K bytes to read, and the page size is 4K bytes, the array must have 11 elements, 10 for the data and one element for the NULL.

Each buffer must be at least the size of a system memory page, and must be aligned on a system memory page size boundary. The system will read one system memory page of data into each buffer.

The function stores the data in the buffers in a sequential manner. That is, it stores data into the first buffer, then into the second buffer, then into the next, filling each buffer, until there is no more data or there are no more buffers.

The union pointed to by aSegmentArray and by lpReserved, FILE_SEGMENT_ELEMENT, is defined as follows:

typedef union _FILE_SEGMENT_ELEMENT {
    PVOID64 Buffer;
    ULONGLONG Alignment;
}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;

Requirements

OS Versions: Windows CE 5.0 and later

Header: FsdMgr.h.

Link Library: Fsdmgr.lib.

See Also

MyFSD_WriteFileGather

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.