Merge pull request #573 from kbinny62/master

xmltest: create dir resources/out to avoid crashes
This commit is contained in:
Lee Thomason 2017-07-06 16:52:00 -07:00 committed by GitHub
commit 7096e779d0
1 changed files with 14 additions and 1 deletions

View File

@ -5,16 +5,20 @@
#endif #endif
#include "tinyxml2.h" #include "tinyxml2.h"
#include <cerrno>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
#if defined( _MSC_VER ) #if defined( _MSC_VER ) || defined (WIN32)
#include <crtdbg.h> #include <crtdbg.h>
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
_CrtMemState startMemState; _CrtMemState startMemState;
_CrtMemState endMemState; _CrtMemState endMemState;
#else
#include <sys/stat.h>
#include <sys/types.h>
#endif #endif
using namespace tinyxml2; using namespace tinyxml2;
@ -334,6 +338,15 @@ int main( int argc, const char ** argv )
} }
fclose( fp ); fclose( fp );
#if defined WIN32
if ( !CreateDirectory( "resources\\out", NULL ) && GetLastError() != ERROR_ALREADY_EXISTS ) {
#else
if ( mkdir( "resources/out", S_IRWXU | S_IRGRP | S_IXGRP ) == -1 && errno != EEXIST ) {
#endif
printf( "Unable to create directory 'resources/out': %s\n", strerror( errno ) );
exit( 1 );
}
XMLTest( "Example-1", 0, example_1() ); XMLTest( "Example-1", 0, example_1() );
XMLTest( "Example-2", 0, example_2() ); XMLTest( "Example-2", 0, example_2() );
XMLTest( "Example-3", 0, example_3() ); XMLTest( "Example-3", 0, example_3() );