FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | List of all members
FotoSHOCKcore::IO::File Class Reference

#include <File.hpp>

Public Member Functions

 File (const char *path, const char *mode) throw (IOException)
 Open the specified file. More...
 
void close () throw (IOException)
 Close the file. More...
 
 ~File ()
 Destructor. More...
 
FILE * get ()
 Get pointer to opened file. More...
 

Detailed Description

Class used for opening files. File class using RAII (Resource Acquisition Is Initialization) technique. This ensures that the file is properly closed even when an exception occurs.

Constructor & Destructor Documentation

FotoSHOCKcore::IO::File::File ( const char *  path,
const char *  mode 
)
throw (IOException
)
inline

Open the specified file.

Parameters
pathpath to a file
modemode as defined by the fopen() function
Exceptions
IOExceptionif the file cannot be opened.
FotoSHOCKcore::IO::File::~File ( )
inline

Destructor.

This desctructor closes the file in case it was not closed using the close() function beforehand.

However, in comparison to the close() function, the destructor doesn't report possible errors using the expcetion mechanism. That is because it is dangerous to throw exceptions in destructor and the behaviour is undefined.

Member Function Documentation

void FotoSHOCKcore::IO::File::close ( )
throw (IOException
)
inline

Close the file.

Exceptions
IOExceptionif the file can't be closed.
FILE* FotoSHOCKcore::IO::File::get ( )
inline

Get pointer to opened file.

Returns
FILE* pointer to the opened file.

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