fplayer
C99 Falcon Sequence (fseq) file player for Light-O-Rama hardware (like xLights)
Loading...
Searching...
No Matches
fc.h File Reference

File controller interface for reading/writing files. More...

#include <stdint.h>
Include dependency graph for fc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  fc_mode_t { FC_MODE_READ , FC_MODE_WRITE }
 File controller open mode. More...
 

Functions

struct FCFC_open (const char *fp, enum fc_mode_t mode)
 Opens a file controller instance for the given file path and mode.
 
void FC_close (struct FC *fc)
 Closes the given file controller instance and frees its resources.
 
uint32_t FC_read (struct FC *fc, uint32_t offset, uint32_t size, uint8_t *b)
 Reads the given number of bytes from the file controller starting at the given offset.
 
uint32_t FC_readto (struct FC *fc, uint32_t offset, uint32_t size, uint32_t maxCount, uint8_t *b)
 Reads up to the given number of bytes from the file controller starting at the given offset, up to the given maximum count of bytes or until the end of the file is reached.
 
uint32_t FC_write (struct FC *fc, uint32_t offset, uint32_t size, const uint8_t *b)
 Writes the given number of bytes to the file controller starting at the given offset.
 
uint32_t FC_filesize (struct FC *fc)
 Returns the size of the file backing the given file controller. This performs a seek to the end of the file to determine its size and then seeks back to the beginning.
 

Detailed Description

File controller interface for reading/writing files.

Enumeration Type Documentation

◆ fc_mode_t

enum fc_mode_t

File controller open mode.

Enumerator
FC_MODE_READ 

Equivalent to "rb".

FC_MODE_WRITE 

Equivalent to "wb".

Function Documentation

◆ FC_close()

void FC_close ( struct FC * fc)

Closes the given file controller instance and frees its resources.

Parameters
fctarget file controller instance
Here is the caller graph for this function:

◆ FC_filesize()

uint32_t FC_filesize ( struct FC * fc)

Returns the size of the file backing the given file controller. This performs a seek to the end of the file to determine its size and then seeks back to the beginning.

Parameters
fctarget file controller instance
Returns
the size of the file in bytes, or 0 if an error occurred
Here is the caller graph for this function:

◆ FC_open()

struct FC * FC_open ( const char * fp,
enum fc_mode_t mode )

Opens a file controller instance for the given file path and mode.

Parameters
fpfile path to open
modefile open mode
Returns
a file controller instance, or NULL if an error occurred
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FC_read()

uint32_t FC_read ( struct FC * fc,
uint32_t offset,
uint32_t size,
uint8_t * b )

Reads the given number of bytes from the file controller starting at the given offset.

Parameters
fctarget file controller instance
offsetoffset in bytes from the start of the file
sizenumber of bytes to read
bbuffer to read into
Returns
the number of bytes read, otherwise 0 or a value less than size if an error occurred
Here is the caller graph for this function:

◆ FC_readto()

uint32_t FC_readto ( struct FC * fc,
uint32_t offset,
uint32_t size,
uint32_t maxCount,
uint8_t * b )

Reads up to the given number of bytes from the file controller starting at the given offset, up to the given maximum count of bytes or until the end of the file is reached.

Parameters
fctarget file controller instance
offsetoffset in bytes from the start of the file
sizenumber of bytes to read
maxCountmaximum number of bytes to read
bbuffer to read into
Returns
the number of bytes read, otherwise 0 or a value less than size if an error occurred
Here is the caller graph for this function:

◆ FC_write()

uint32_t FC_write ( struct FC * fc,
uint32_t offset,
uint32_t size,
const uint8_t * b )

Writes the given number of bytes to the file controller starting at the given offset.

Parameters
fctarget file controller instance
offsetoffset in bytes from the start of the file
sizenumber of bytes to write
bbuffer to write
Returns
the number of bytes written, otherwise 0 or a value less than size if an error occurred
Here is the caller graph for this function: