mirror of
https://github.com/serge1/ELFIO.git
synced 2025-04-16 05:42:31 +00:00
Added overload to elfio::save which accepts std::ostream
This commit is contained in:
parent
e64acb2b2e
commit
925af0d3d5
@ -148,9 +148,19 @@ class elfio
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool save( const std::string& file_name )
|
bool save( const std::string& file_name )
|
||||||
{
|
{
|
||||||
std::ofstream f( file_name.c_str(), std::ios::out | std::ios::binary );
|
std::ofstream stream;
|
||||||
|
stream.open( file_name.c_str(), std::ios::out | std::ios::binary );
|
||||||
|
if ( !stream ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !f || !header) {
|
return save(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
bool save( std::ostream &stream )
|
||||||
|
{
|
||||||
|
if ( !stream || !header) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,11 +184,9 @@ class elfio
|
|||||||
is_still_good = is_still_good && layout_sections_without_segments();
|
is_still_good = is_still_good && layout_sections_without_segments();
|
||||||
is_still_good = is_still_good && layout_section_table();
|
is_still_good = is_still_good && layout_section_table();
|
||||||
|
|
||||||
is_still_good = is_still_good && save_header( f );
|
is_still_good = is_still_good && save_header( stream );
|
||||||
is_still_good = is_still_good && save_sections( f );
|
is_still_good = is_still_good && save_sections( stream );
|
||||||
is_still_good = is_still_good && save_segments( f );
|
is_still_good = is_still_good && save_segments( stream );
|
||||||
|
|
||||||
f.close();
|
|
||||||
|
|
||||||
return is_still_good;
|
return is_still_good;
|
||||||
}
|
}
|
||||||
@ -482,13 +490,13 @@ class elfio
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool save_header( std::ofstream& f )
|
bool save_header( std::ostream& f )
|
||||||
{
|
{
|
||||||
return header->save( f );
|
return header->save( f );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool save_sections( std::ofstream& f )
|
bool save_sections( std::ostream& f )
|
||||||
{
|
{
|
||||||
for ( unsigned int i = 0; i < sections_.size(); ++i ) {
|
for ( unsigned int i = 0; i < sections_.size(); ++i ) {
|
||||||
section *sec = sections_.at(i);
|
section *sec = sections_.at(i);
|
||||||
@ -503,7 +511,7 @@ class elfio
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool save_segments( std::ofstream& f )
|
bool save_segments( std::ostream& f )
|
||||||
{
|
{
|
||||||
for ( unsigned int i = 0; i < segments_.size(); ++i ) {
|
for ( unsigned int i = 0; i < segments_.size(); ++i ) {
|
||||||
segment *seg = segments_.at(i);
|
segment *seg = segments_.at(i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user