libcaca  0.99.beta19
About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).
  Fossies Dox: libcaca-0.99.beta19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

libcaca file IO

These functions allow to read and write files in a platform-independent way. More...

Functions

caca_file_tcaca_file_open (char const *, const char *)
 Open a file for reading or writing. More...
 
int caca_file_close (caca_file_t *)
 Close a file handle. More...
 
uint64_t caca_file_tell (caca_file_t *)
 Return the position in a file handle. More...
 
size_t caca_file_read (caca_file_t *, void *, size_t)
 Read data from a file handle. More...
 
size_t caca_file_write (caca_file_t *, const void *, size_t)
 Write data to a file handle. More...
 
char * caca_file_gets (caca_file_t *, char *, int)
 Read a line from a file handle. More...
 
int caca_file_eof (caca_file_t *)
 Tell whether a file handle reached end of file. More...
 

Detailed Description

These functions allow to read and write files in a platform-independent way.

Function Documentation

◆ caca_file_close()

int caca_file_close ( caca_file_t )

Close a file handle.

Close and destroy the resources associated with a caca file handle.

This function is a wrapper for fclose() or, if available, gzclose().

Parameters
fpThe file handle
Returns
The return value of fclose() or gzclose().

Definition at line 151 of file file.c.

References f, and seterrno.

Referenced by caca_import_canvas_from_file(), cucul_load_file(), load_image(), and open_charfont().

◆ caca_file_eof()

int caca_file_eof ( caca_file_t )

Tell whether a file handle reached end of file.

Return the end-of-file status of the file handle.

This function is a wrapper for feof() or, if available, gzeof().

Parameters
fpThe file handle
Returns
1 if EOF was reached, 0 otherwise

Definition at line 298 of file file.c.

References f.

Referenced by caca_import_canvas_from_file(), cucul_load_file(), and open_charfont().

◆ caca_file_gets()

char * caca_file_gets ( caca_file_t ,
char *  ,
int   
)

Read a line from a file handle.

Read one line of data from a file handle, up to one less than the given number of bytes. A trailing zero is appended to the data.

Parameters
fpThe file handle
sThe destination buffer
sizeThe maximum number of bytes to read
Returns
The number of bytes read, including the trailing zero

Definition at line 255 of file file.c.

References f, and seterrno.

Referenced by open_charfont().

◆ caca_file_open()

caca_file_t * caca_file_open ( char const *  ,
const char *   
)

Open a file for reading or writing.

Create a caca file handle for a file. If the file is zipped, it is decompressed on the fly.

If an error occurs, NULL is returned and errno is set accordingly:

  • ENOSTS Function not implemented.
  • EINVAL File not found or permission denied.
Parameters
pathThe file path
modeThe file open mode
Returns
A file handle to path.

Definition at line 64 of file file.c.

References f, mode, readonly, and seterrno.

Referenced by caca_import_canvas_from_file(), cucul_load_file(), load_image(), and open_charfont().

◆ caca_file_read()

size_t caca_file_read ( caca_file_t ,
void *  ,
size_t   
)

Read data from a file handle.

Read data from a file handle and copy them into the given buffer.

Parameters
fpThe file handle
ptrThe destination buffer
sizeThe number of bytes to read
Returns
The number of bytes read

Definition at line 199 of file file.c.

References f, and seterrno.

Referenced by caca_import_canvas_from_file(), cucul_load_file(), load_image(), u16fread(), u32fread(), and u8fread().

◆ caca_file_tell()

uint64_t caca_file_tell ( caca_file_t )

Return the position in a file handle.

Return the file handle position, in bytes.

Parameters
fpThe file handle
Returns
The current offset in the file handle.

Definition at line 176 of file file.c.

References f, and seterrno.

◆ caca_file_write()

size_t caca_file_write ( caca_file_t ,
const void *  ,
size_t   
)

Write data to a file handle.

Write the contents of the given buffer to the file handle.

Parameters
fpThe file handle
ptrThe source buffer
sizeThe number of bytes to write
Returns
The number of bytes written

Definition at line 222 of file file.c.

References f, readonly, and seterrno.