MCPcopy Create free account
hub / github.com/Kitware/VTK / CanReadFile

Method CanReadFile

IO/Parallel/vtkPDataSetReader.cxx:382–426  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

380
381//------------------------------------------------------------------------------
382int vtkPDataSetReader::CanReadFile(const char* filename)
383{
384 istream* file;
385 char* block;
386 char* param;
387 char* value;
388 int type;
389 int flag = 0;
390
391 // Start reading the meta-data pvtk file.
392 file = this->OpenFile(filename);
393 if (file == nullptr)
394 {
395 return 0;
396 }
397
398 type = this->ReadXML(file, &block, &param, &value);
399 if (type == 1 && strcmp(block, "File") == 0)
400 {
401 // We cannot leave the XML parser in a bad state.
402 // As a quick fix, read to the end of the file block.
403 // A better solution would be to move statistics
404 // to ivars and initialize them as needed.
405 while (this->ReadXML(file, &block, &param, &value) != 5)
406 {
407 }
408 flag = 1;
409 }
410
411 if (type == 4 && strncmp(value, "# vtk DataFile Version", 22) == 0)
412 {
413 // This is a vtk file.
414 vtkDataSetReader* tmp = vtkDataSetReader::New();
415 tmp->SetFileName(filename);
416 type = tmp->ReadOutputType();
417 if (type != -1)
418 {
419 flag = 1;
420 }
421 tmp->Delete();
422 }
423
424 delete file;
425 return flag;
426}
427
428//------------------------------------------------------------------------------
429void vtkPDataSetReader::ReadPVTKFileInformation(

Callers

nothing calls this directly

Calls 6

OpenFileMethod · 0.95
ReadXMLMethod · 0.95
DeleteMethod · 0.65
NewFunction · 0.50
SetFileNameMethod · 0.45
ReadOutputTypeMethod · 0.45

Tested by

no test coverage detected