ePass1000 C/C++ API Reference Manual Version 2.0

epas_CreateFile

The epas_CreateFile function create a file in the current directory. Applications must have changed current directory to the directory under which file is to be created by invoking epas_ChangeDir. Application must also have the proper privilege to create a file.

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

Requirement

epas_CreateContext, epas_OpenDevice

Parameters

hContextHandle
[in] Handle to device context.
ulFlags
[in] Reserved for future extension and must be set to zero.
pFileInfo
[in] Pointer to an EPAS_FILEINFO structure that defines information of the file to be created.

You should first zero initialize this structure and set corresponding fields. See EPAS_FILEINFO structure.

ulSizeOfFileInfo
[in] size of the buffer that pFileInfo parameter points.

Remarks

It is recommended that application only create files under their own defined Application Directory and not under the root directory. To create an Application Directory, See the epas_CreateDir function.

File create operation will automatically close currently opened file, even if the file create failed.

File creation access is controlled through the Global Access Control. To obtain the Global Access Control, use the epas_GetProperty function. To set the Global Access Control, use the epas_SetProperty function.

For a list of reserved file IDs, see EPAS_FILEINFO.

Return Values

If the function succeeds, FT_SUCCESS returned.

If file creation access is not granted, FT_ACCESS_DENIED is returned.

If a file with the given ID already exists, FT_ALREADY_EXISTS is returned.

If the free space of the device is not big enough to create the file, FT_NOT_ENOUGH_MEMORY is returned.

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

Sample Code

EPAS_STATUS epsRet;
EPAS_HANDLE handle;

EPAS_FILEINFO fi;


ZeroMemory(&fi,sizeof(EPAS_FILEINFO));

fi.ulID = 0xEF03;
fi.ucFileType = EPAS_FILETYPE_DATA;
fi.ulFileSize = 50;
fi.ucReadAccess = EPAS_ACCESS_ANYONE;
fi.ucWriteAccess = EPAS_ACCESS_ANYONE;
fi.ucCryptAccess = EPAS_ACCESS_ANYONE;

epsRet = epas_CreateFile(handle,0,&fi,sizeof(EPAS_FILEINFO));.
.
.
.

See Also

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