------------------------------------------------------------------------------
| 657 | |
| 658 | //------------------------------------------------------------------------------ |
| 659 | int 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 |