C-chat
Classes | Typedefs | Functions
files.h File Reference

Provides an API to manipulate files. More...

Go to the source code of this file.

Classes

class  FileInfo
 A class containing information about a file. More...
 

Typedefs

typedef struct FileInfo FileInfo
 

Functions

FileInfo files_getInfo (const char *filename)
 Retrieves information about the file with the given name. More...
 
unsigned long files_readFile (const char *filename, char *contentBuffer, unsigned long bufferSize)
 Reads the given file. More...
 
unsigned long files_writeFile (const char *filename, const char *contentBuffer, unsigned long bufferSize)
 Writes the given file. More...
 

Detailed Description

Provides an API to manipulate files.

Function Documentation

◆ files_getInfo()

FileInfo files_getInfo ( const char *  filename)

Retrieves information about the file with the given name.

Parameters
filenameThe name of the file to get information of
Returns
the information of the file with the given name

◆ files_readFile()

unsigned long files_readFile ( const char *  filename,
char *  contentBuffer,
unsigned long  bufferSize 
)

Reads the given file.

An error can occur if :

  • the given file is a directory
  • the given file is protected against reading
  • the given buffer is too small for the specified size
Parameters
filenameThe name of the file to read
contentBufferThe buffer to store file content in
bufferSizeThe size of the given buffer
Returns
the actually read size or -1 if an error occurred

◆ files_writeFile()

unsigned long files_writeFile ( const char *  filename,
const char *  contentBuffer,
unsigned long  bufferSize 
)

Writes the given file.

An error can occur if :

  • the given file is a directory
  • the given file is protected against writing
  • the given buffer is too small for the specified size
Parameters
filenameThe name of the file to write to
contentBufferThe buffer to get file content from
bufferSizeThe size of the given buffer
Returns
the actually written size or -1 if an error occurred