5.13.0.0R1
Software Development Kit
wicedfs.h File Reference

Data Structures

struct  wicedfs_dir_struct
 
struct  wicedfs_file_struct
 
struct  wicedfs_filesystem_struct
 

Typedefs

typedef wicedfs_usize_t(* wicedfs_read_func_t) (void *user_param, void *buf, wicedfs_usize_t size, wicedfs_usize_t pos)
 

Functions

int wicedfs_closedir (wicedfs_dir_t *dirp)
 
int wicedfs_eodir (wicedfs_dir_t *dirp)
 
int wicedfs_fclose (wicedfs_file_t *stream)
 
int wicedfs_feof (wicedfs_file_t *stream)
 
wicedfs_ssize_t wicedfs_filesize (const wicedfs_filesystem_t *fs_handle, const char *filename)
 
int wicedfs_fopen (const wicedfs_filesystem_t *fs_handle, wicedfs_file_t *handle, const char *filename)
 
wicedfs_usize_t wicedfs_fread (void *data, wicedfs_usize_t size, wicedfs_usize_t count, wicedfs_file_t *stream)
 
int wicedfs_fseek (wicedfs_file_t *stream, wicedfs_ssize_t offset, int whence)
 
wicedfs_usize_t wicedfs_ftell (wicedfs_file_t *stream)
 
int wicedfs_init (wicedfs_usize_t base, wicedfs_read_func_t read_func, wicedfs_filesystem_t *fs_handle, void *user_param)
 
int wicedfs_opendir (const wicedfs_filesystem_t *fs_handle, wicedfs_dir_t *handle, const char *dirname)
 
int wicedfs_readdir_with_size (wicedfs_dir_t *dirp, char *name_buf, unsigned int name_buf_len, wicedfs_entry_type_t *type, wicedfs_usize_t *size)
 
void wicedfs_rewinddir (wicedfs_dir_t *dirp)
 

Detailed Description

Public API of the WicedFS Read-Only file system.

Typedef Documentation

typedef wicedfs_usize_t(* wicedfs_read_func_t) (void *user_param,void *buf, wicedfs_usize_t size, wicedfs_usize_t pos)

Typedef of Read Function which will be used to read data from the hardware device.

Parameters
[in]user_param- The user_param value passed when wicedfs_init was called (use for hardware device handles)
[out]buf- The buffer to be filled with data
[in]size- The number of bytes to read
[in]pos- Absolute hardware device location to read from
Returns
Number of bytes successfully read (i.e. 0 on failure)

Function Documentation

int wicedfs_closedir ( wicedfs_dir_t dirp)

Closes a directory handle

Parameters
[in]dirp- the directory handle to close
Returns
0 = Success
int wicedfs_eodir ( wicedfs_dir_t dirp)

Check the end-of-directory flag for a directory

Checks whether the selected directory handle is at the end of the available directory entries.

Parameters
[in]stream- the file handle to check for EOF
Returns
1 = End-of-Directory
int wicedfs_fclose ( wicedfs_file_t stream)

Close a file

This is similar to the fclose() in ISO C.

Parameters
[in]stream- the file handle to close
Returns
0 = success
int wicedfs_feof ( wicedfs_file_t stream)

Check the end-of-file flag for a stream

This is similar to the feof() in ISO C.

Parameters
[in]stream- the file handle to check for EOF
Returns
1 = EOF
wicedfs_ssize_t wicedfs_filesize ( const wicedfs_filesystem_t fs_handle,
const char *  filename 
)

Returns the size of a file

Parameters
[in]filename- The filename of the file to examine
[in]fs_handle- The filesystem handle to use - obtained from wicedfs_init
Returns
The size in bytes of the file, or negative on error
int wicedfs_fopen ( const wicedfs_filesystem_t fs_handle,
wicedfs_file_t handle,
const char *  filename 
)

Open a file for reading

Since the filesystem is read-only, a "file mode" is not needed.

Parameters
[in]fs_handle- The filesystem handle to use - obtained from wicedfs_init
[out]handle- a pointer to a wicedfs_file_t structure which will receive the file handle after it is opened
[in]filename- The filename of the file to open
Returns
0 on success
wicedfs_usize_t wicedfs_fread ( void *  data,
wicedfs_usize_t  size,
wicedfs_usize_t  count,
wicedfs_file_t stream 
)

Reads data from a file into a memory buffer

This is similar to the fread() in ISO C.

Parameters
[out]data- A pointer to the memory buffer that will receive the data that is read
[in]size- the number of bytes per item
[in]count- the number of items to read i.e. total bytes read = size * count
[in]stream- the file handle to read from
Returns
the number of items successfully read.
int wicedfs_fseek ( wicedfs_file_t stream,
wicedfs_ssize_t  offset,
int  whence 
)

Seek to a location within a file

This is similar to the fseek() in ISO C.

Parameters
[in]stream- The file handle on which to perform the seek. Must have been previously opened with wicedfs_fopen.
[in]offset- The offset in bytes
[in]whence- SEEK_SET = Offset from start of file SEEK_CUR = Offset from current position in file SEEK_END = Offset from end of file
Returns
0 on success
wicedfs_usize_t wicedfs_ftell ( wicedfs_file_t stream)

Returns the current location within a file

This is similar to the ftell() in ISO C.

Parameters
[in]stream- The file handle to be examined
Returns
The current location within the file
int wicedfs_init ( wicedfs_usize_t  base,
wicedfs_read_func_t  read_func,
wicedfs_filesystem_t fs_handle,
void *  user_param 
)

Initialise the file system

Initialises the filesystem for use. This function reads data from a hardware device via a function pointer. It assumes that the device is ready to read immediately.

Parameters
[in]base- The location on the hardware device where the filesystem start header resides.
[in]read_func- Function pointer to be used for reading hardware
[out]fs_handle- Receives the filesystem handle to be used when opening files/directories.
[in]user_param- A user parameter which will be passed to the WICEDFS_READ macro. e.g. for hardware device handles
Returns
0 on success
int wicedfs_opendir ( const wicedfs_filesystem_t fs_handle,
wicedfs_dir_t handle,
const char *  dirname 
)

Opens a directory

This is similar to the opendir() in ISO C.

Parameters
[in]fs_handle- The filesystem handle to use - obtained from wicedfs_init
[out]handle- a pointer to a directory structure which will be filled with the opened handle
[in]dirname- the path of the directory to open
Returns
0 = Success
int wicedfs_readdir_with_size ( wicedfs_dir_t dirp,
char *  name_buf,
unsigned int  name_buf_len,
wicedfs_entry_type_t *  type,
wicedfs_usize_t *  size 
)

Reads a directory entry

This is similar to the readdir() in ISO C.

Parameters
[in]dirp- the directory handle to read from
[out]name_buf- pointer to a buffer that will receive the filename
[in]name_buf_len- the maximum number of bytes that can be put in the buffer
[out]type- pointer to variable that will receive entry type (file or dir)
[out]size- pointer to variable that will receive the file size (dir size is zero)
Returns
0 = Success
void wicedfs_rewinddir ( wicedfs_dir_t dirp)

Returns a directory handle to the first entry

This is similar to the rewinddir() in ISO C.

Parameters
[in]dirp- the directory handle to rewind