.TH "caca_file" 3caca "Wed Mar 10 2021" "Version 0.99.beta19" "libcaca" \" -*- nroff -*- .ad l .nh .SH NAME caca_file \- libcaca file IO .SH SYNOPSIS .br .PP .SS "Modules" .in +1c .ti -1c .RI "\fBlibcaca importers/exporters from/to various\fP" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "__extern \fBcaca_file_t\fP * \fBcaca_file_open\fP (char const *, const char *)" .br .RI "Open a file for reading or writing\&. " .ti -1c .RI "__extern int \fBcaca_file_close\fP (\fBcaca_file_t\fP *)" .br .RI "Close a file handle\&. " .ti -1c .RI "__extern uint64_t \fBcaca_file_tell\fP (\fBcaca_file_t\fP *)" .br .RI "Return the position in a file handle\&. " .ti -1c .RI "__extern size_t \fBcaca_file_read\fP (\fBcaca_file_t\fP *, void *, size_t)" .br .RI "Read data from a file handle\&. " .ti -1c .RI "__extern size_t \fBcaca_file_write\fP (\fBcaca_file_t\fP *, const void *, size_t)" .br .RI "Write data to a file handle\&. " .ti -1c .RI "__extern char * \fBcaca_file_gets\fP (\fBcaca_file_t\fP *, char *, int)" .br .RI "Read a line from a file handle\&. " .ti -1c .RI "__extern int \fBcaca_file_eof\fP (\fBcaca_file_t\fP *)" .br .RI "Tell whether a file handle reached end of file\&. " .in -1c .SH "Detailed Description" .PP These functions allow to read and write files in a platform-independent way\&. .SH "Function Documentation" .PP .SS "__extern \fBcaca_file_t\fP* caca_file_open (char const * path, const char * mode)" Create a caca file handle for a file\&. If the file is zipped, it is decompressed on the fly\&. .PP If an error occurs, NULL is returned and \fBerrno\fP is set accordingly: .IP "\(bu" 2 \fCENOSTS\fP Function not implemented\&. .IP "\(bu" 2 \fCEINVAL\fP File not found or permission denied\&. .PP .PP \fBParameters\fP .RS 4 \fIpath\fP The file path .br \fImode\fP The file open mode .RE .PP \fBReturns\fP .RS 4 A file handle to \fIpath\fP\&. .RE .PP .PP Referenced by caca_import_canvas_from_file()\&. .SS "__extern int caca_file_close (\fBcaca_file_t\fP * fp)" Close and destroy the resources associated with a caca file handle\&. .PP This function is a wrapper for fclose() or, if available, gzclose()\&. .PP \fBParameters\fP .RS 4 \fIfp\fP The file handle .RE .PP \fBReturns\fP .RS 4 The return value of fclose() or gzclose()\&. .RE .PP .PP Referenced by caca_import_canvas_from_file()\&. .SS "__extern uint64_t caca_file_tell (\fBcaca_file_t\fP * fp)" Return the file handle position, in bytes\&. .PP \fBParameters\fP .RS 4 \fIfp\fP The file handle .RE .PP \fBReturns\fP .RS 4 The current offset in the file handle\&. .RE .PP .SS "__extern size_t caca_file_read (\fBcaca_file_t\fP * fp, void * ptr, size_t size)" Read data from a file handle and copy them into the given buffer\&. .PP \fBParameters\fP .RS 4 \fIfp\fP The file handle .br \fIptr\fP The destination buffer .br \fIsize\fP The number of bytes to read .RE .PP \fBReturns\fP .RS 4 The number of bytes read .RE .PP .PP Referenced by caca_import_canvas_from_file()\&. .SS "__extern size_t caca_file_write (\fBcaca_file_t\fP * fp, const void * ptr, size_t size)" Write the contents of the given buffer to the file handle\&. .PP \fBParameters\fP .RS 4 \fIfp\fP The file handle .br \fIptr\fP The source buffer .br \fIsize\fP The number of bytes to write .RE .PP \fBReturns\fP .RS 4 The number of bytes written .RE .PP .SS "__extern char* caca_file_gets (\fBcaca_file_t\fP * fp, char * s, int size)" 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\&. .PP \fBParameters\fP .RS 4 \fIfp\fP The file handle .br \fIs\fP The destination buffer .br \fIsize\fP The maximum number of bytes to read .RE .PP \fBReturns\fP .RS 4 The number of bytes read, including the trailing zero .RE .PP .SS "__extern int caca_file_eof (\fBcaca_file_t\fP * fp)" Return the end-of-file status of the file handle\&. .PP This function is a wrapper for feof() or, if available, gzeof()\&. .PP \fBParameters\fP .RS 4 \fIfp\fP The file handle .RE .PP \fBReturns\fP .RS 4 1 if EOF was reached, 0 otherwise .RE .PP .PP Referenced by caca_import_canvas_from_file()\&. .SH "Author" .PP Generated automatically by Doxygen for libcaca from the source code\&.