From 186476c665b16104e8939486001ecc3732799760 Mon Sep 17 00:00:00 2001 From: Martell Date: Thu, 6 Sep 2012 16:41:46 +0100 Subject: [PATCH] Shut up visual studio --- tinyxml2.cpp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 8069d04..7ef6d44 100644 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1509,16 +1509,15 @@ int XMLDocument::LoadFile( const char* filename ) { DeleteChildren(); InitDocument(); + FILE* fp = 0; -#if defined(_MSC_VER) -#pragma warning ( push ) -#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated. -#endif - FILE* fp = fopen( filename, "rb" ); -#if defined(_MSC_VER) -#pragma warning ( pop ) -#endif - if ( !fp ) { + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + errno_t err = fopen_s(&fp, filename, "rb" ); + if ( !fp || err) { + #else + fp = fopen( filename, "rb" ); + if ( !fp) { + #endif SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 ); return errorID; } @@ -1565,18 +1564,17 @@ int XMLDocument::LoadFile( FILE* fp ) int XMLDocument::SaveFile( const char* filename ) { -#if defined(_MSC_VER) -#pragma warning ( push ) -#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated. -#endif - FILE* fp = fopen( filename, "w" ); -#if defined(_MSC_VER) -#pragma warning ( pop ) -#endif - if ( !fp ) { + FILE* fp = 0; + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + errno_t err = fopen_s(&fp, filename, "w" ); + if ( !fp || err) { + #else + fp = fopen( filename, "rb" ); + if ( !fp) { + #endif SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 ); return errorID; - } + } SaveFile(fp); fclose( fp ); return errorID;