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

File controller implementation. More...

#include "fc.h"
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for fc.c:

Data Structures

struct  FC
 File controller that wraps a stdlib file pointer and provides additional functionality for reading files, including thread-safe access. More...
 

Functions

struct FCFC_open (const char *const fp, const 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, const uint32_t offset, const uint32_t size, uint8_t *const b)
 Reads the given number of bytes from the file controller starting at the given offset.
 
uint32_t FC_readto (struct FC *fc, const uint32_t offset, const uint32_t size, const uint32_t maxCount, uint8_t *const 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, const uint32_t offset, const uint32_t size, const uint8_t *const 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 implementation.

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: