mirror of https://github.com/AxioDL/tinyxml2.git
merge fix for save file error
This commit is contained in:
commit
f657783cf2
|
@ -1879,6 +1879,9 @@ XMLError XMLDocument::SaveFile( const char* filename, bool compact )
|
||||||
|
|
||||||
XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
|
XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
|
||||||
{
|
{
|
||||||
|
// Clear any error from the last save, otherwise it will get reported
|
||||||
|
// for *this* call.
|
||||||
|
SetError( XML_NO_ERROR, 0, 0 );
|
||||||
XMLPrinter stream( fp, compact );
|
XMLPrinter stream( fp, compact );
|
||||||
Print( &stream );
|
Print( &stream );
|
||||||
return _errorID;
|
return _errorID;
|
||||||
|
|
|
@ -1433,6 +1433,14 @@ int main( int argc, const char ** argv )
|
||||||
XMLPrinter printer;
|
XMLPrinter printer;
|
||||||
newElement->Accept( &printer );
|
newElement->Accept( &printer );
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
// Issue 302. Clear errors from LoadFile/SaveFile
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.SaveFile( "./no/such/path/pretty.xml" );
|
||||||
|
XMLTest( "Issue 302. Fail to save", doc.ErrorName(), "XML_ERROR_FILE_COULD_NOT_BE_OPENED" );
|
||||||
|
doc.SaveFile( "./resources/out/compact.xml", true );
|
||||||
|
XMLTest( "Issue 302. Subsequent success in saving", doc.ErrorName(), "XML_SUCCESS" );
|
||||||
|
}
|
||||||
|
|
||||||
// ----------- Performance tracking --------------
|
// ----------- Performance tracking --------------
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue