FF_CreateIOMAN()

From FullFAT
Jump to: navigation, search


Creates an FF_IOMAN type object and returns a pointer to it.

This object is required when calling all FullFAT API functions. This provides re-entrancy, and inter-device isolation.

Contents

Prototype

FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 BlkSize, FF_ERROR *pError);

Back to API.

Parameters

pCacheMem

A pointer to a byte-wise buffer, of size 'Size' that FullFAT can use for its work buffers. No more than 8Kb should be required for really good performance.

This parameter can be NULL, in which case, FullFAT uses malloc() to allocate the memory itself. The size of the provided buffer must be a multiple of BlkSize.

Size

The size of the provided buffer. It must be atleast a single multiple of the specified BlkSize.

BlkSize

The block size of the device driver that FullFAT should expect to work in. If this changes (as with some secure USB sticks) you will need to destroy the FF_IOMAN object using the FF_DestroyIOMAN() function, and recreate a new FF_IOMAN object again.

pError

A pointer to an FF_ERROR variable. This can be NULL if you aren't checking for errors. The error code returned from here, can be passed to FF_GetErrMessage() to get a useful message describing the error.

The value of pError should only be checked if FF_CreateIOMAN() returns NULL.

Return Value

The function returns a non-zero value if it succeeds. If the function fails, it returns NULL (0) and sets the provided FF_ERROR parameter.

Example

#include "fullfat.h"
 
FF_IOMAN *pIoman;
FF_ERROR Error;
 
pIoman = FF_CreateIOMAN(NULL, 8192, 512, &Error);     // FullFAT uses malloc() to allocate the memory.
#include "fullfat.h"
 
FF_IOMAN *pIoman;
FF_ERROR Error;
 
char myBuffer[8192];
 
pIoman = FF_CreateIOMAN(myBuffer, 8192, 512, &Error);     // FullFAT uses memory provided by myBuffer (on the stack).

Back to API.

See Also

Personal tools