PUMA Library Reference Manual
Puma::FileSource Class Reference

#include <Puma/FileSource.h>

+ Inheritance diagram for Puma::FileSource:

Description

File wrapper implementing the Source interface.

Public Member Functions

 FileSource (const char *path, ErrorSink *err=(ErrorSink *) 0)
 Construct a new file wrapper. More...
 
 ~FileSource ()
 Destroy the file wrapper. More...
 
virtual int read (char *dest, int n)
 Read n bytes from the file into the given string. More...
 
- Public Member Functions inherited from Puma::FdSource
 FdSource ()
 Construct a new file descriptor wrapper with invalid file descriptor. More...
 
 FdSource (int fdesc)
 Construct a new wrapper for the given file descriptor. More...
 
virtual ~FdSource ()
 Destroy the wrapper. More...
 
void fd (int fdesc)
 Set the wrapped file descriptor. More...
 
int fd ()
 Get the wrapped file descriptor. More...
 
int size ()
 Get the size of the file. More...
 
- Public Member Functions inherited from Puma::Source
 Source ()
 Constructs an empty source object. More...
 
virtual ~Source ()
 Destroys the source object. More...
 

Constructor & Destructor Documentation

◆ FileSource()

Puma::FileSource::FileSource ( const char *  path,
ErrorSink err = (ErrorSink*) 0 
)
inline

Construct a new file wrapper.

Opens the given file in read-only mode.

Parameters
pathThe path to the file.
errOptional error stream.

◆ ~FileSource()

Puma::FileSource::~FileSource ( )
inline

Destroy the file wrapper.

Closes the file opened in the constructor.

Member Function Documentation

◆ read()

virtual int Puma::FileSource::read ( char *  dest,
int  n 
)
inlinevirtual

Read n bytes from the file into the given string.

Parameters
destThe string used as buffer for the bytes read.
nThe number of bytes to read.
Returns
The number of bytes read, or -1 in case of errors.

Reimplemented from Puma::FdSource.