io

Name

io -- Binary I/O operations.

Synopsis


#include <io.h>
       namespace ::io
{
    
   void  writeData( int  fd, const  void*  pData,  size_t  size)
          throws int;
       size_t  readData ( int  fd,  void*  pBuffer,  size_t  nBytes)
          throws int;
  
}
   

DESCRIPTION

Provides encapsulations of the read(2) and write(2) system calls that transparently handles the various edge cases that may cause premature I/O termination.

METHODS

void writeData( int fd, const void* pData, size_t size) throws int;

Writes size bytes of data pointed to by pData to the file descriptor fd. When this function returns either all of the bytes have been writtren or an int exception has been thrown whose value is errno at the time the exception was thrown.

size_t readData ( int fd, void* pBuffer, size_t nBytes) throws int;

Reads at most nBytes of data from the file descriptor fd into the buffer pointed to by pBuffer. Returns the number of bytes actually written. When this function returns one of the following is true:

  • All nBytes of data have been read.

  • The return value is less than nBytes. This means an end of file condition was encountered when reading the data. The return value is the nuber of bytes actually transferred.

  • The function has thrown an int exception indicating an error of some sort. The value of the integer thrown is errno at the time the error was detected.