added open_binary_file...

master
_xeroxz 4 years ago
parent 99a1fc74e1
commit fdcafdbbcb

@ -67,6 +67,24 @@ namespace xtils
return &obj;
}
auto open_binary_file( const std::string &file, std::vector< uint8_t > &data ) -> bool
{
std::ifstream fstr( file, std::ios::binary );
if ( !fstr.is_open() )
return false;
fstr.unsetf( std::ios::skipws );
fstr.seekg( 0, std::ios::end );
const auto file_size = fstr.tellg();
fstr.seekg( NULL, std::ios::beg );
data.reserve( static_cast< uint32_t >( file_size ) );
data.insert( data.begin(), std::istream_iterator< uint8_t >( fstr ), std::istream_iterator< uint8_t >() );
return true;
}
auto image_base( const char *image_path ) -> std::uintptr_t
{
char image_header[ PAGE_4K ];

Loading…
Cancel
Save