Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

io.h File Reference

Input/output functions. More...

#include <libcomprex/file.h>
#include <libcomprex/fp.h>
#include <libcomprex/types.h>

Go to the source code of this file.

Functions

CxFPcxOpenFile (const char *path, CxAccessMode mode)
 Opens a file from a local or remote filesystem, or in an archive.

CxFPcxOpenFileHandle (CxFile *file, CxAccessMode mode)
 Opens a file from an existing file handle (CxFile structure).

CxFPcxOpenStream (FILE *stream)
 Opens an existing FILE * stream.

CxFPcxOpenBuffer (char *buffer, size_t size)
 Opens a stream from a buffer.

void cxClose (CxFP *fp)
 Closes a file pointer.

size_t cxRead (void *ptr, size_t size, size_t nmemb, CxFP *fp)
 Reads data from a file pointer.

size_t cxWrite (const void *ptr, size_t size, size_t nmemb, CxFP *fp)
 Writes data to a file pointer.

void cxSeek (CxFP *fp, long offset, int whence)
 Seeks to a position in the file.

void cxRewind (CxFP *fp)
 Rewinds to the beginning of the stream.

long cxTell (CxFP *fp)
 Returns the current position in the file.

void cxClearErr (CxFP *fp)
 Clears the error flag and end-of-file indicator.

int cxEof (CxFP *fp)
 Tests the end-of-file indicator.

int cxError (CxFP *fp)
 Tests the error indicator of the file.

const char * cxStrError (CxFP *fp, int errnum)
 Returns a string representation of the error.


Detailed Description

Input/output functions.

Id:
io.h,v 1.4 2002/05/26 09:47:07 chipx86 Exp
Copyright:
(C) 2001-2002 The GNUpdate Project.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Function Documentation

void cxClearErr CxFP   fp
 

Clears the error flag and end-of-file indicator.

Parameters:
fp  The file pointer.
See also:
cxEof() , cxError() , cxStrError()

void cxClose CxFP   fp
 

Closes a file pointer.

The CxFP structure will be freed after this is called.

Parameters:
fp  The file pointer to close.
See also:
cxOpenBuffer() , cxOpenFile() , cxOpenFileHandle() , cxOpenStream()

int cxEof CxFP   fp
 

Tests the end-of-file indicator.

Parameters:
fp  The file pointer.
Returns:
1 if the end-of-file indicator is set; 0 otherwise.
See also:
cxClearErr() , cxError() , cxStrError()

int cxError CxFP   fp
 

Tests the error indicator of the file.

Parameters:
fp  The file pointer.
Returns:
The error if set, or 0 on no error.
See also:
cxClearErr() , cxEof() , cxStrError()

CxFP* cxOpenBuffer char *    buffer,
size_t    size
 

Opens a stream from a buffer.

Parameters:
buffer  The buffer.
size  The size of the buffer.
Returns:
The file pointer, or NULL on error.
See also:
cxOpenFile() , cxOpenFileHandle() , cxOpenStream() , cxClose()

CxFP* cxOpenFile const char *    path,
CxAccessMode    mode
 

Opens a file from a local or remote filesystem, or in an archive.

Parameters:
path  The path to the file.
mode  The access mode.
Returns:
The file pointer, if the file exists. NULL otherwise.
See also:
cxOpenBuffer() , cxOpenFileHandle() , cxOpenStream() , cxClose()

CxFP* cxOpenFileHandle CxFile   file,
CxAccessMode    mode
 

Opens a file from an existing file handle (CxFile structure).

Parameters:
file  The file handle.
mode  The access mode.
Returns:
The file pointer, or NULL if it's unable to open.
See also:
cxOpenBuffer() , cxOpenFile() , cxOpenStream() , cxClose()

CxFP* cxOpenStream FILE *    stream
 

Opens an existing FILE * stream.

Parameters:
stream  The stream to read from.
Returns:
The new file pointer, or NULL on error.
See also:
cxOpenBuffer() , cxOpenFile() , cxOpenFileHandle() , cxClose()

size_t cxRead void *    ptr,
size_t    size,
size_t    nmemb,
CxFP   fp
 

Reads data from a file pointer.

Parameters:
ptr  The buffer which will store the data.
size  The size of an element of data.
nmemb  The number of elements of size @size to receive.
fp  The file pointer to read from.
Returns:
The number of elements read, or 0 on error or end of file.
See also:
cxRewind() , cxSeek() , cxTell() , cxWrite()

void cxRewind CxFP   fp
 

Rewinds to the beginning of the stream.

Parameters:
fp  The file pointer.
See also:
cxSeek() , cxTell()

void cxSeek CxFP   fp,
long    offset,
int    whence
 

Seeks to a position in the file.

Parameters:
fp  The file pointer.
offset  The relative or absolute offset to seek to.
whence  SEEK_SET, SEEK_CUR, or SEEK_END.
See also:
cxRewind() , cxTell()

const char* cxStrError CxFP   fp,
int    errnum
 

Returns a string representation of the error.

Parameters:
fp  The file pointer.
errnum  The error number.
Returns:
The string representation of the error.
See also:
cxClearErr() , cxEof() , cxError()

long cxTell CxFP   fp
 

Returns the current position in the file.

Parameters:
fp  The file pointer.
Returns:
The current position in the file.
See also:
cxRewind() , cxSeek()

size_t cxWrite const void *    ptr,
size_t    size,
size_t    nmemb,
CxFP   fp
 

Writes data to a file pointer.

Parameters:
ptr  The data to write.
size  The size of an element of data.
nmemb  The number of elements of size @size to receive.
fp  The file pointer to write to.
Returns:
The number of elements written, or 0 on error.
See also:
cxRead() , cxSeek() , cxTell() , cxRewind()


Generated on Wed May 29 12:20:35 2002 for libcomprex by doxygen1.2.15-20020430