My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions | Variables
sw_filelib.c File Reference
#include "sw_filelib.h"
#include "sw_syslibc.h"
#include "sw_types.h"
#include "sw_buddy.h"
#include "sw_mem_functions.h"
#include "sw_string_functions.h"
#include "sw_debug.h"
#include "fat32.h"

Functions

FILEfopen (const unsigned char *name, const unsigned char *mode)
 function shall open the file whose pathname is the string pointed to by filename, and associates a stream with it More...
 
unsigned int fread (void *out_buf, unsigned int size, unsigned int count, FILE *inputstream)
 Reads an array of count elements from an inputstream. More...
 
unsigned int fwrite (const void *content, unsigned int size, unsigned int count, FILE *pfile)
 fwrite - Writes an array of count elements to an outputstream More...
 
int fclose (FILE *pfile)
 fclose - function will flushes the stream pointed to by filepointer More...
 
int() feof (FILE *file_stream)
 feof - Checks whether the end-of-File indicator associated with stream is set More...
 
int fseek (FILE *seekstream, long offset, int whence)
 fseek - Sets the position indicator associated with the stream to a new position More...
 
int remove (const char *r_pth)
 remove - Deletes the file whose name is specified in filename More...
 

Variables

FILE BUF_IO [SW_FILEOPEN_MAX]
 
int errno
 

Function Documentation

int fclose ( FILE pfile)

fclose - function will flushes the stream pointed to by filepointer

Parameters
pfile- Pointer to a FILE object that specifies the stream to be closed
Returns
- If the stream is successfully closed, a zero value is returned. On failure, EOF is returned
int() feof ( FILE file_stream)

feof - Checks whether the end-of-File indicator associated with stream is set

Parameters
file_stream- Pointer to a FILE object that identifies the stream
Returns
- A non-zero value is returned in the case that the end-of-file indicator associated with the stream is set.Otherwise, zero is returned
FILE* fopen ( const unsigned char *  name,
const unsigned char *  mode 
)

function shall open the file whose pathname is the string pointed to by filename, and associates a stream with it

Parameters
name- string containing the name of the file to be opened
mode- string containing a file access mode
Returns
- Upon successful completion, fopen() shall return a pointer to the object controlling the stream. Otherwise, a null pointer shall be returned
unsigned int fread ( void *  out_buf,
unsigned int  size,
unsigned int  count,
FILE inputstream 
)

Reads an array of count elements from an inputstream.

Parameters
out_buf- Pointer to a block of memory with a size of at least (size*count) bytes
size- Size in bytes, of each element to be read
count- Number of elements, each one with a size of size bytes
inputstream- Pointer to a FILE object that specifies an input stream
Returns
- The total number of elements successfully read is returned if this number differs from the count parameter, either a reading error occurred or the end-of-file was reached while reading. In both cases, -1 is returned
int fseek ( FILE seekstream,
long  offset,
int  whence 
)

fseek - Sets the position indicator associated with the stream to a new position

Parameters
seekstream- Pointer to a FILE object that identifies the stream
offset- Number of bytes to offset from origin
whence- Position used as reference for the offset for reference sw_filelibc.h
Returns
- If successful, the function returns zero. Otherwise, it returns non-zero value
unsigned int fwrite ( const void *  content,
unsigned int  size,
unsigned int  count,
FILE pfile 
)

fwrite - Writes an array of count elements to an outputstream

Parameters
content- Pointer to the array of elements to be written
size- Size in bytes of each element to be written
count- Number of elements, each one with a size of size bytes
pfile- Pointer to a FILE object that specifies an output stream
Returns
- The total number of elements successfully written is returned. If this number differs from the count parameter -1 is returned
int remove ( const char *  r_pth)

remove - Deletes the file whose name is specified in filename

Parameters
r_pth- string containing the name of the file to be deleted
Returns
- if the file is successfully deleted, a zero value is returned. On failure, a non-zero value is returned

Variable Documentation

Initial value:
= {
{ 0, 0, SW_READ,0,(unsigned char *) 0,(unsigned char *) 0},
{ 0, 1, SW_WRITE,0,(unsigned char *) 0,(unsigned char *) 0},
{ 0, 2, SW_WRITE | SW_IOLBF,0,(unsigned char *) 0,(unsigned char *) 0},
{0,0,0,0,0,0}
}
#define SW_READ
Definition: sw_filelib.h:30
#define SW_WRITE
Definition: sw_filelib.h:31
#define SW_IOLBF
Definition: sw_filelib.h:42
int errno