------------------------------------------------------------------------------
| 427 | |
| 428 | //------------------------------------------------------------------------------ |
| 429 | void vtkPDataSetReader::ReadPVTKFileInformation( |
| 430 | istream* file, vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) |
| 431 | { |
| 432 | char* block; |
| 433 | char* param; |
| 434 | char* val; |
| 435 | int type; |
| 436 | int ext[6]; |
| 437 | double vect[3]; |
| 438 | int i; |
| 439 | char *pfn, *pdir; |
| 440 | int count, dirLength; |
| 441 | char dir[512]; |
| 442 | |
| 443 | vtkInformation* info = outputVector->GetInformationObject(0); |
| 444 | |
| 445 | // The file block should have a version parameter. |
| 446 | type = this->ReadXML(file, &block, ¶m, &val); |
| 447 | if (type != 2 || strcmp(param, "version") != 0) |
| 448 | { |
| 449 | vtkErrorMacro("Could not find file version."); |
| 450 | return; |
| 451 | } |
| 452 | if (strcmp(val, "pvtk-1.0") != 0) |
| 453 | { |
| 454 | vtkDebugMacro("Unexpected Version."); |
| 455 | } |
| 456 | |
| 457 | // Extract the directory form the filename so we can complete relative paths. |
| 458 | count = dirLength = 0; |
| 459 | pfn = this->FileName; |
| 460 | pdir = dir; |
| 461 | // Copy filename to dir, and keep track of the last slash. |
| 462 | while (*pfn != '\0' && count < 512) |
| 463 | { |
| 464 | *pdir++ = *pfn++; |
| 465 | ++count; |
| 466 | if (*pfn == '/' || *pfn == '\\') |
| 467 | { |
| 468 | // The extra +1 is to keep the last slash. |
| 469 | dirLength = count + 1; |
| 470 | } |
| 471 | } |
| 472 | // This trims off every thing after the last slash. |
| 473 | dir[dirLength] = '\0'; |
| 474 | |
| 475 | // We are in the start file block. |
| 476 | // Read parameters until we terminate the start block. |
| 477 | while ((type = this->ReadXML(file, &block, ¶m, &val)) != 3) |
| 478 | { |
| 479 | if (type == 0) |
| 480 | { |
| 481 | vtkErrorMacro("Early termination of pvtk file."); |
| 482 | return; |
| 483 | } |
| 484 | if (type != 2) |
| 485 | { // There should be no other possibility. Param will not be nullptr. |
| 486 | vtkErrorMacro("Expecting a parameter."); |
no test coverage detected