ePass1000 C/C++ API Reference Manual Version 2.0

epas_OpenFile

The epas_OpenFile function opens the file that associated with the given file ID in the current directory.

EPAS_STATUS EPAS_API
epas_OpenFile(
    EPAS_HANDLE hContextHandle,       // [in]
    unsigned long ulFlags,            // [in]
    unsigned long ulFileID,           // [in]
    PEPAS_FILEINFO pFileInfo,         // [out]
    unsigned long ulSizeOfFileInfo    // [in]
);

Requirement

epas_CreateContext, epas_OpenDevice, epas_ChangeDir

Parameters

hContextHandle
[in] Handle to device context.
ulFlags
[in] A bit mask defined the required file access mode. You may use OR operation to select more than one access mode.
Flag Meaning
0 Open the file. The file access mode is based on the currently granted access privilege of the file.
EPAS_FILE_READ Open the file for reading.
EPAS_FILE_WRITE Open the file for writing.
EPAS_FILE_CRYPT Open the file for cryptographic operations.
ulFileID
[in] ID of the file to be opened.
pFileInfo
[out] Pointer to an EPAS_FILEINFO structure, which contain information about the file.

The file information is returned upon a successful open. You should first zero initialize this structure before calling the function. You may ignore this parameter by set the value to NULL.

ulSizeOfFileInfo
[in] Size of the buffer that pFileInfo points to. If pFileInfo parameter is NULL, this parameter must be set to zero.

Remarks

The file access right depends on access setting of the file and current Security State of the device. For example, if the file write requires a USER PIN access, the write privilege is only granted in User State or SO State.

The granted access setting of the file is returned in the EPAS_FILEINFO structure upon a successful open. To retrieve the granted access rights of a file, use a flag of zero.

To obtain access setting of a file, use epas_GetFileInfo.

epas_OpenFile automatically closes current opened file, even if failed to open the specified file.

Upon a successful creation of a directory, the current directory will be set to the newly created directory.

For a list of reserved directory IDs, see EPAS_FILEINFO.

Return Values

If the function succeeds, FT_SUCCESS returned.

If the specified file does not exist, FT_FILE_NOT_FOUND is returned.

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

Sample Code

EPAS_STATUS epsRet;
EPAS_HANDLE handle;
.
.
.
epsRet = epas_OpenFile(	handle,0,DEMO_FILE_ID,&fi,sizeof(EPAS_FILEINFO));
.
.
.

See Also

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