ePass1000 C/C++ API Reference Manual Version 2.0

# epas_Write

The epas_Write function writes data to the currently opened file at a given offset. Application need write access privilege to the file to invoke this function successfully.

    EPAS_STATUS EPAS_API
    epas_Write(
        EPAS_HANDLE hContextHandle,         // [in]
        unsigned long ulFlags,              // [in]
        unsigned long ulOffset,             // [in]
        unsigned char* pucBuffer,           // [in]
        unsigned long ulBytesToWrite,       // [in]
        unsigned long* pulBytesWritten      // [out]
    );

#### Requirement

epas_CreateContext, epas_OpenDevice, epas_OPenFile or epas_CreateFile

#### Parameters

hContextHandle
  [in] Handle to device context.
ulFlags
  [in] Reserved for future extension and must be set to zero.
ulOffset
  [in] A zero-based value defining the relative distance from the beginning of the file.
pucBuffer
  [in] Pointer to a buffer that contains data to be written to the file.
ulBytesToWrite
  [in] Number of bytes to be written.

  For EPAS_SYS_TYPE1 file system, this value cannot exceed size of the file. You must delete the file and then re-create it to resize it.

pulBytesWritten

  [out] Pointer to a variable which returns the number of bytes actually written to the file. This parameter can NOT be NULL.

#### Remarks

Property access rights is required to write a file successfully. The granted access setting and file type is returned from the epas_OpenFile function in the EPAS_FILEINFO structure.

#### Return Values

If the function succeeds, FT_SUCCESS returned.

If write access to the file has not granted, FT_ACCESS_DENIED returned.

For a list of all return codes, see Status Return Values.

#### Sample Code

    EPAS_STATUS epsRet;
    EPAS_HANDLE handle;
    .
    .
    .
    unsigned long ulWritten;
    epsRet = epas_Write(handle,0,0,pBuf,DEMO_FILE_SIZE,&ulWritten);
    .
    .
    .

#### See Also

epas_CreateFile, epas_DeleteFile, epas_OpenFile, epas_CloseFile, epas_GetFileInfo, epas_Read, epas_CreateDir, epas_DeleteDir, epas_GetCurrentDir, epas_ChangeDir, epas_Directory