+ // -----------------------------------------------------------------------
+ inline bool WriteBufferToFile(
+ const std::string& buffer, const std::string& fname
+ )
+ {
+ std::ofstream file_stream(
+ CanonicalPath( fname ).c_str( ), std::ofstream::binary
+ );
+ if( !file_stream )
+ return( false );
+ file_stream.write( buffer.c_str( ), buffer.size( ) );
+ return( true );
+ }
+
+ // -----------------------------------------------------------------------
+ inline bool ReadFileIntoBuffer(
+ std::string& buffer, const std::string& fname
+ )
+ {
+ buffer = "";
+ std::ifstream file_stream(
+ CanonicalPath( fname ).c_str( ), std::ifstream::binary
+ );
+ if( !file_stream )
+ return( false );
+ file_stream.seekg( 0, std::ios::end );
+ buffer.reserve( ( unsigned int )( file_stream.tellg( ) ) );
+ file_stream.seekg( 0, std::ios::beg );
+ buffer.assign(
+ ( std::istreambuf_iterator< char >( file_stream ) ),
+ std::istreambuf_iterator< char >( )
+ );
+ file_stream.close( );
+ return( true );
+ }
+