PUMA Library Reference Manual
Loading...
Searching...
No Matches
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.
 
 ~FileSource ()
 Destroy the file wrapper.
 
virtual int read (char *dest, int n)
 Read n bytes from the file into the given string.
 
- Public Member Functions inherited from Puma::FdSource
 FdSource ()
 Construct a new file descriptor wrapper with invalid file descriptor.
 
 FdSource (int fdesc)
 Construct a new wrapper for the given file descriptor.
 
virtual ~FdSource ()
 Destroy the wrapper.
 
void fd (int fdesc)
 Set the wrapped file descriptor.
 
int fd ()
 Get the wrapped file descriptor.
 
int size ()
 Get the size of the file.
 
- Public Member Functions inherited from Puma::Source
 Source ()
 Constructs an empty source object.
 
virtual ~Source ()
 Destroys the source object.
 

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.