@ -17,8 +17,8 @@ std::pair<bool,std::string> ReadBinaryFile(const fs::path &filename, size_t maxs
return std : : make_pair ( false , " " ) ;
return std : : make_pair ( false , " " ) ;
std : : string retval ;
std : : string retval ;
char buffer [ 128 ] ;
char buffer [ 128 ] ;
size_t n ;
do {
while ( ( n = fread ( buffer , 1 , sizeof ( buffer ) , f ) ) > 0 ) {
const size_t n = fread ( buffer , 1 , sizeof ( buffer ) , f ) ;
// Check for reading errors so we don't return any data if we couldn't
// Check for reading errors so we don't return any data if we couldn't
// read the entire file (or up to maxsize)
// read the entire file (or up to maxsize)
if ( ferror ( f ) ) {
if ( ferror ( f ) ) {
@ -26,9 +26,7 @@ std::pair<bool,std::string> ReadBinaryFile(const fs::path &filename, size_t maxs
return std : : make_pair ( false , " " ) ;
return std : : make_pair ( false , " " ) ;
}
}
retval . append ( buffer , buffer + n ) ;
retval . append ( buffer , buffer + n ) ;
if ( retval . size ( ) > maxsize )
} while ( ! feof ( f ) & & retval . size ( ) < = maxsize ) ;
break ;
}
fclose ( f ) ;
fclose ( f ) ;
return std : : make_pair ( true , retval ) ;
return std : : make_pair ( true , retval ) ;
}
}