MCPcopy Create free account
hub / github.com/9miao/CrossApp / SaveFile

Method SaveFile

CrossApp/support/tinyxml2/tinyxml2.cpp:1641–2100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1639
1640
1641XMLError XMLDocument::SaveFile( const char* filename, bool compact )
1642{
1643 FILE* fp = 0;
1644#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
1645 errno_t err = fopen_s(&fp, filename, "w" );
1646 if ( !fp || err) {
1647#else
1648 fp = fopen( filename, "w" );
1649 if ( !fp) {
1650#endif
1651 SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 );
1652 return _errorID;
1653 }
1654 SaveFile(fp, compact);
1655 fclose( fp );
1656 return _errorID;
1657}
1658
1659
1660XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
1661{
1662 XMLPrinter stream( fp, compact );
1663 Print( &stream );
1664 return _errorID;
1665}
1666
1667
1668XMLError XMLDocument::Parse( const char* p, size_t len )
1669{
1670 DeleteChildren();
1671 InitDocument();
1672
1673 if ( !p || !*p ) {
1674 SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
1675 return _errorID;
1676 }
1677 if ( len == (size_t)(-1) ) {
1678 len = strlen( p );
1679 }
1680 _charBuffer = new char[ len+1 ];
1681 memcpy( _charBuffer, p, len );
1682 _charBuffer[len] = 0;
1683
1684 p = XMLUtil::SkipWhiteSpace( p );
1685 p = XMLUtil::ReadBOM( p, &_writeBOM );
1686 if ( !p || !*p ) {
1687 SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
1688 return _errorID;
1689 }
1690
1691 ParseDeep( _charBuffer, 0 );
1692 return _errorID;
1693}
1694
1695
1696void XMLDocument::Print( XMLPrinter* streamer )
1697{
1698 XMLPrinter stdStreamer( stdout );

Callers 3

deleteNodeFunction · 0.80
setValueForKeyFunction · 0.80
createXMLFileMethod · 0.80

Calls 1

PrintClass · 0.85

Tested by

no test coverage detected