Commit 668ab1ef authored by Brian Wylie's avatar Brian Wylie
Browse files

ENH: Add 'CanReadFile' method to exodus reader.

parent e06be20d
......@@ -1391,7 +1391,7 @@ void vtkExodusMetadata::Finalize()
}
vtkCxxRevisionMacro(vtkExodusReader, "1.10");
vtkCxxRevisionMacro(vtkExodusReader, "1.11");
vtkStandardNewMacro(vtkExodusReader);
#ifdef ARRAY_TYPE_NAMES_IN_CXX_FILE
......@@ -1423,6 +1423,44 @@ const char *vtkExodusReader::ArrayTypeNames[NUM_ARRAY_TYPES] = {
};
#endif
// Helper function
int vtkExodusReaderFileExist(const char *file_name)
{
struct stat fs;
if (file_name)
{
return (stat(file_name, &fs) != -1);
}
else
{
return 0;
}
}
// Description:
// Determine if the file can be readed with this reader.
int vtkExodusReader::CanReadFile(const char* fname)
{
// First see if the file exists at all
if (vtkExodusReaderFileExist(fname) == 0)
{
return 0;
}
// Okay now see if it's really an exodus file
int returnVal = ex_open( fname, EX_READ,
&(this->ExodusCPUWordSize),
&(this->ExodusIOWordSize),
&(this->ExodusVersion));
// Failure
if (returnVal < 0)
{
return 0;
}
// Success
return 1;
}
//----------------------------------------------------------------------------
// Description:
// Instantiate object with NULL filename.
......@@ -2090,20 +2128,6 @@ void vtkExodusReader::SetDisplayType(int type){
this->DisplayType=type;
}
// Helper function
int vtkExodusReaderFileExist(char *file_name)
{
struct stat fs;
if (file_name)
{
return (stat(file_name, &fs) != -1);
}
else
{
return 0;
}
}
//----------------------------------------------------------------------------
int vtkExodusReader::RequestInformation(
vtkInformation *vtkNotUsed(request),
......
......@@ -59,6 +59,10 @@ public:
static vtkExodusReader *New();
vtkTypeRevisionMacro(vtkExodusReader,vtkUnstructuredGridAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Determine if the file can be readed with this reader.
int CanReadFile(const char* fname);
// Description:
// Specify file name of the Exodus file.
......
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