return( res );
}
- // -----------------------------------------------------------------------
- inline bool ReadFileIntoBuffer(
- std::string& buffer, const std::string& fname
- )
- {
- buffer = "";
- std::ifstream file_stream( fname.c_str( ) );
- 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 );
- }
-
// -----------------------------------------------------------------------
inline std::string CanonicalPath( const std::string& path )
{
return( ret );
}
+ // -----------------------------------------------------------------------
+ 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 );
+ }
+
} // ecapseman
#endif // __CPPLUGINS__UTILITY__H__