libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches
CMUTIL_FileStream Struct Reference

File stream object for reading and writing files. More...

Data Fields

ssize_t(* Read )(const CMUTIL_FileStream *fs, CMUTIL_String *buffer, size_t size)
 Read data from the file stream into a buffer.
 
ssize_t(* Write )(const CMUTIL_FileStream *fs, const CMUTIL_String *buffer, size_t offset, size_t size)
 Write data from a buffer to the file stream.
 
void(* Close )(CMUTIL_FileStream *fs)
 Close the file stream and free its resources.
 

Detailed Description

File stream object for reading and writing files.

Field Documentation

◆ Read

ssize_t(* CMUTIL_FileStream::Read) (const CMUTIL_FileStream *fs, CMUTIL_String *buffer, size_t size)

Read data from the file stream into a buffer.

This method only available if this object created with CMFileOpenRead mode, otherwise will return -1.

Parameters
fsA pointer to the CMUTIL_FileStream object.
bufferA pointer to the buffer where the read data will be stored.
sizeThe number of bytes to read from the file stream.
Returns
The number of bytes actually read, or -1 on failure.

◆ Write

ssize_t(* CMUTIL_FileStream::Write) (const CMUTIL_FileStream *fs, const CMUTIL_String *buffer, size_t offset, size_t size)

Write data from a buffer to the file stream.

This method only available if this object created with CMFileOpenWrite or CMFileOpenAppend mode, otherwise will return -1.

Parameters
fsA pointer to the CMUTIL_FileStream object.
bufferA pointer to the buffer containing the data to write.
offsetThe offset in the buffer from which to start writing.
sizeThe number of bytes to write to the file stream.
Returns
The number of bytes actually written, or -1 on failure.

◆ Close

void(* CMUTIL_FileStream::Close) (CMUTIL_FileStream *fs)

Close the file stream and free its resources.

Parameters
fsA pointer to the CMUTIL_FileStream object to be closed.

The documentation for this struct was generated from the following file: