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

Method IsFileValid

IO/Legacy/vtkDataReader.cxx:659–703  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

657
658//------------------------------------------------------------------------------
659int vtkDataReader::IsFileValid(const char* dstype)
660{
661 char line[256];
662
663 if (!dstype)
664 {
665 return 0;
666 }
667
668 if (!this->OpenVTKFile() || !this->ReadHeader())
669 {
670 this->CloseVTKFile();
671 return 0;
672 }
673
674 if (!this->ReadString(line))
675 {
676 vtkErrorMacro(<< "Data file ends prematurely!");
677 this->CloseVTKFile();
678 this->SetErrorCode(vtkErrorCode::PrematureEndOfFileError);
679 return 0;
680 }
681
682 if (!strncmp(this->LowerCase(line), "dataset", 7))
683 {
684 if (!this->ReadString(line))
685 {
686 vtkErrorMacro(<< "Data file ends prematurely!");
687 this->CloseVTKFile();
688 this->SetErrorCode(vtkErrorCode::PrematureEndOfFileError);
689 return 0;
690 }
691 if (strncmp(this->LowerCase(line), dstype, strlen(dstype)) != 0)
692 {
693 this->CloseVTKFile();
694 return 0;
695 }
696 // everything looks good
697 this->CloseVTKFile();
698 return 1;
699 }
700
701 this->CloseVTKFile();
702 return 0;
703}
704
705//------------------------------------------------------------------------------
706// Read the cell data of a vtk data file. The number of cells (from the

Callers 6

IsFileStructuredPointsFunction · 0.80
IsFilePolyDataFunction · 0.80
IsFileStructuredGridFunction · 0.80
IsFileUnstructuredGridFunction · 0.80
IsFileRectilinearGridFunction · 0.80

Calls 5

OpenVTKFileMethod · 0.95
ReadHeaderMethod · 0.95
CloseVTKFileMethod · 0.95
ReadStringMethod · 0.95
LowerCaseMethod · 0.95

Tested by 1