| 512 | } |
| 513 | |
| 514 | void vtkPDataSetWriter::DeleteFiles() |
| 515 | { |
| 516 | int i; |
| 517 | int length = static_cast<int>(strlen(this->FileName)); |
| 518 | std::vector<char> fileRoot(length + 1); |
| 519 | size_t fileNameSize = length + this->FilePatternStdFormat.size() + 20; |
| 520 | std::vector<char> fileName(fileNameSize); |
| 521 | |
| 522 | strncpy(fileRoot.data(), this->FileName, length); |
| 523 | fileRoot[length] = '\0'; |
| 524 | // Trim off the pvtk extension. |
| 525 | if (strncmp(fileRoot.data() + length - 5, ".pvtk", 5) == 0) |
| 526 | { |
| 527 | fileRoot[length - 5] = '\0'; |
| 528 | } |
| 529 | if (strncmp(fileRoot.data() + length - 4, ".vtk", 4) == 0) |
| 530 | { |
| 531 | fileRoot[length - 4] = '\0'; |
| 532 | } |
| 533 | // If we are using relative file names, trim off the directory path. |
| 534 | if (this->UseRelativeFileNames) |
| 535 | { |
| 536 | char *tmp, *slash; |
| 537 | // Find the last / or \ in the file name. |
| 538 | slash = nullptr; |
| 539 | tmp = fileRoot.data(); |
| 540 | while (*tmp != '\0') |
| 541 | { |
| 542 | if (*tmp == '/' || *tmp == '\\') |
| 543 | { |
| 544 | slash = tmp; |
| 545 | } |
| 546 | ++tmp; |
| 547 | } |
| 548 | // Copy just the filename into root. |
| 549 | if (slash) |
| 550 | { |
| 551 | ++slash; |
| 552 | tmp = fileRoot.data(); |
| 553 | while (*slash != '\0') |
| 554 | { |
| 555 | *tmp++ = *slash++; |
| 556 | } |
| 557 | *tmp = '\0'; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | for (i = this->StartPiece; i <= this->EndPiece; i++) |
| 562 | { |
| 563 | auto result = vtk::format_to_n( |
| 564 | fileName.data(), fileNameSize, this->FilePatternStdFormat, fileRoot.data(), i); |
| 565 | *result.out = '\0'; |
| 566 | remove(fileName.data()); |
| 567 | } |
| 568 | |
| 569 | remove(this->FileName); |
| 570 | } |
| 571 |
no test coverage detected