You are currently viewing the documentation for:
ECF_ReadFile
ECF_ReadFile reads data from an open file.
ECF_ErrorCode ECF_ReadFile(
   struct ECF_FileHandle *pFileHandle,
   BYTE *data,
   UINT size
);
Parameters
pFileHandle
A pointer to an open file handle.
data
A pointer to a buffer big enough to hold the read data.
size
The number of bytes to read.
Return value
Returns one of the ECF error codes (ECFERR_SUCCESS on success)
Remarks
None.
Example Code
#include <ECF/ECF.h>

#define COPYFILE_BUFFERSIZE   4096

void CopyFile(const char *cszSource, const char *cszDestination)
{
   struct ECF_FileHandle srcFile;
   struct ECF_FileHandle destFile;
   DWORD dwDataLeftToCopy;
   DWORD dwDataToCopyNow;
   BYTE abCopyBuffer[COPYFILE_BUFFERSIZE];

   // Error checking omitted
   ECF_OpenFile(&srcFile, cszSource, ECF_MODE_READ);
   ECF_OpenFile(&destFile, cszDestination, ECF_MODE_READ_WRITE);

   ECF_GetFileSize(&srcFile, &dwDataLeftToCopy);

   while(dwDataLeftToCopy)
   {
      dwDataToCopyNow = COPYFILE_BUFFERSIZE;
      if(dwDataToCopyNow > dwDataLeftToCopy)
         dwDataToCopyNow = dwDataLeftToCopy;
      
      ECF_ReadFile(&srcFile, abCopyBuffer, dwDataToCopyNow);
      ECF_WriteFile(&destFile, abCopyBuffer, dwDataToCopyNow);
   
      dwDataLeftToCopy -= dwDataToCopyNow;
   }
   ECF_CloseFile(&destFile);
   ECF_CloseFile(&srcFile);
}
See also