Commit 4e531cd0 authored by Dan Lipsa's avatar Dan Lipsa
Browse files

ENH: CanReadFile does not fail for newer file version.

CanReadFile does not fail for newer file versions to enable clients (ParaView)
to distinguish between reader failures caused by a mismatch between the file
and the reader, and reader failures that cannot be fixed by changing the reader.

A warning will be printed when reading a file with a newer version than the reader.

Legacy readers already behave this way.
parent 0181ce42
...@@ -631,9 +631,9 @@ int vtkXMLReader::ReadVTKFile(vtkXMLDataElement* eVTKFile) ...@@ -631,9 +631,9 @@ int vtkXMLReader::ReadVTKFile(vtkXMLDataElement* eVTKFile)
const char* version = eVTKFile->GetAttribute("version"); const char* version = eVTKFile->GetAttribute("version");
if (version && !this->CanReadFileVersionString(version)) if (version && !this->CanReadFileVersionString(version))
{ {
vtkErrorMacro("File version: " << version << " is is higher than " vtkWarningMacro("File version: " << version << " is higher than "
"this reader supports. Cannot read file."); "this reader supports " << vtkXMLReaderMajorVersion << "."
return 0; << vtkXMLReaderMinorVersion);
} }
::ReadStringVersion(version, this->FileMajorVersion, this->FileMinorVersion); ::ReadStringVersion(version, this->FileMajorVersion, this->FileMinorVersion);
...@@ -839,18 +839,7 @@ int vtkXMLReader::CanReadFile(const char* name) ...@@ -839,18 +839,7 @@ int vtkXMLReader::CanReadFile(const char* name)
{ {
if (this->CanReadFileWithDataType(tester->GetFileDataType())) if (this->CanReadFileWithDataType(tester->GetFileDataType()))
{ {
const char* version = tester->GetFileVersion(); result = 1;
if (version)
{
if (this->CanReadFileVersionString(version))
{
result = 3;
}
}
else
{
result = 3;
}
} }
} }
......
...@@ -55,8 +55,11 @@ public: ...@@ -55,8 +55,11 @@ public:
void SetInputString(std::string s) { this->InputString = s; } void SetInputString(std::string s) { this->InputString = s; }
// Description: // Description:
// Test whether the file with the given name can be read by this // Test whether the file (type) with the given name can be read by this
// reader. // reader. If the file has a newer version than the reader, we still say
// we can read the file type and we fail later, when we try to read the file.
// This enables clients (ParaView) to distinguish between failures when we
// need to look for another reader and failures when we don't.
virtual int CanReadFile(const char* name); virtual int CanReadFile(const char* name);
// Description: // Description:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment