fix for missing valid images

This commit is contained in:
Ken Martin 2004-04-01 16:07:30 -05:00
parent cb90652dca
commit c92c5e4e15
1 changed files with 53 additions and 27 deletions

View File

@ -2949,6 +2949,31 @@ std::string cmCTest::GenerateRegressionImages(const std::string& xml)
if ( cmSystemTools::FileExists(filename.c_str()) )
{
long len = cmSystemTools::FileLength(filename.c_str());
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\t<NamedMeasurement"
<< " " << k1 << "=\"" << v1 << "\""
<< " " << k2 << "=\"" << v2 << "\""
<< " encoding=\"none\""
<< "><Value>Image " << filename.c_str()
<< " is empty</Value></NamedMeasurement>";
}
else
{
std::ifstream ifs(filename.c_str(), std::ios::in
#ifdef _WIN32
| std::ios::binary
@ -2956,7 +2981,7 @@ std::string cmCTest::GenerateRegressionImages(const std::string& xml)
);
unsigned char *file_buffer = new unsigned char [ len + 1 ];
ifs.read(reinterpret_cast<char*>(file_buffer), len);
unsigned char *encoded_buffer = new unsigned char [ static_cast<int>(len * 1.5 + 1) ];
unsigned char *encoded_buffer = new unsigned char [ static_cast<int>(len * 1.5 + 5) ];
unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
unsigned long cc;
@ -2981,6 +3006,7 @@ std::string cmCTest::GenerateRegressionImages(const std::string& xml)
delete [] file_buffer;
delete [] encoded_buffer;
}
}
else
{
int idx = 4;