------------------------------------------------------------------------------
| 380 | |
| 381 | //------------------------------------------------------------------------------ |
| 382 | int 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, ¶m, &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, ¶m, &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 | //------------------------------------------------------------------------------ |
| 429 | void vtkPDataSetReader::ReadPVTKFileInformation( |
nothing calls this directly
no test coverage detected