From c92c5e4e15f5f6297d9862d40f50af848acb7bfe Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 1 Apr 2004 16:07:30 -0500 Subject: fix for missing valid images --- Source/cmCTest.cxx | 76 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 13d3e48..940b0e3 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2949,37 +2949,63 @@ std::string cmCTest::GenerateRegressionImages(const std::string& xml) if ( cmSystemTools::FileExists(filename.c_str()) ) { long len = cmSystemTools::FileLength(filename.c_str()); - std::ifstream ifs(filename.c_str(), std::ios::in + if ( len == 0 ) + { + std::string k1 = measurementfile.match(1); + std::string v1 = measurementfile.match(2); + std::string k2 = measurementfile.match(3); + std::string v2 = measurementfile.match(4); + if ( cmSystemTools::LowerCase(k1) == "type" ) + { + v1 = "text/string"; + } + if ( cmSystemTools::LowerCase(k2) == "type" ) + { + v2 = "text/string"; + } + + ostr + << "\t\t\tImage " << filename.c_str() + << " is empty"; + } + else + { + std::ifstream ifs(filename.c_str(), std::ios::in #ifdef _WIN32 - | std::ios::binary + | std::ios::binary #endif - ); - unsigned char *file_buffer = new unsigned char [ len + 1 ]; - ifs.read(reinterpret_cast(file_buffer), len); - unsigned char *encoded_buffer = new unsigned char [ static_cast(len * 1.5 + 1) ]; - - unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); - unsigned long cc; - - ostr - << "\t\t\t(file_buffer), len); + unsigned char *encoded_buffer = new unsigned char [ static_cast(len * 1.5 + 5) ]; + + unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + unsigned long cc; + + ostr + << "\t\t\t" << std::endl << "\t\t\t\t"; - for ( cc = 0; cc < rlen; cc ++ ) - { - ostr << encoded_buffer[cc]; - if ( cc % 60 == 0 && cc ) + << " " << measurementfile.match(3) << "=\"" << measurementfile.match(4) << "\"" + << " encoding=\"base64\"" + << ">" << std::endl << "\t\t\t\t"; + for ( cc = 0; cc < rlen; cc ++ ) { - ostr << std::endl; + ostr << encoded_buffer[cc]; + if ( cc % 60 == 0 && cc ) + { + ostr << std::endl; + } } + ostr + << "" << std::endl << "\t\t\t" + << std::endl; + delete [] file_buffer; + delete [] encoded_buffer; } - ostr - << "" << std::endl << "\t\t\t" - << std::endl; - delete [] file_buffer; - delete [] encoded_buffer; } else { -- cgit v0.12