mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
Include cleanup Reworked buildsystem (Linux only) Removed dynamic libs, Linux now again uses static linking (like windows)
55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
/** @file
|
|
*
|
|
* @par History
|
|
*/
|
|
|
|
|
|
#include "iohelp.h"
|
|
|
|
#include <stdexcept>
|
|
|
|
// note this is only useful if ofs.exceptions( std::ios_base::failbit | std::ios_base::badbit ) is
|
|
// called
|
|
namespace Pol
|
|
{
|
|
namespace Clib
|
|
{
|
|
void open_file( std::fstream& ofs, std::string& filename, std::ios::openmode mode )
|
|
{
|
|
try
|
|
{
|
|
ofs.open( filename.c_str(), mode );
|
|
}
|
|
catch ( std::exception& ex )
|
|
{
|
|
std::string message = "Error opening file " + filename + ": " + ex.what();
|
|
throw std::runtime_error( message );
|
|
}
|
|
}
|
|
void open_file( std::ofstream& ofs, std::string& filename, std::ios::openmode mode )
|
|
{
|
|
try
|
|
{
|
|
ofs.open( filename.c_str(), mode );
|
|
}
|
|
catch ( std::exception& ex )
|
|
{
|
|
std::string message = "Error opening file " + filename + ": " + ex.what();
|
|
throw std::runtime_error( message );
|
|
}
|
|
}
|
|
|
|
void open_file( std::ifstream& ifs, std::string& filename, std::ios::openmode mode )
|
|
{
|
|
try
|
|
{
|
|
ifs.open( filename.c_str(), mode );
|
|
}
|
|
catch ( std::exception& ex )
|
|
{
|
|
std::string message = "Error opening file " + filename + ": " + ex.what();
|
|
throw std::runtime_error( message );
|
|
}
|
|
}
|
|
}
|
|
}
|