------------------------------------------------------------------------------
| 609 | |
| 610 | //------------------------------------------------------------------------------ |
| 611 | int vtkXMLWriter::OpenFile() |
| 612 | { |
| 613 | delete this->OutFile; |
| 614 | this->OutFile = nullptr; |
| 615 | |
| 616 | // Strip trailing whitespace from the filename. |
| 617 | int len = static_cast<int>(strlen(this->FileName)); |
| 618 | for (int i = len - 1; i >= 0; i--) |
| 619 | { |
| 620 | if (isalnum(this->FileName[i])) |
| 621 | { |
| 622 | break; |
| 623 | } |
| 624 | this->FileName[i] = 0; |
| 625 | } |
| 626 | |
| 627 | std::ios_base::openmode mode = ios::out; |
| 628 | #ifdef _WIN32 |
| 629 | mode |= ios::binary; |
| 630 | #endif |
| 631 | this->OutFile = new vtksys::ofstream(this->FileName, mode); |
| 632 | if (!this->OutFile || !*this->OutFile) |
| 633 | { |
| 634 | vtkErrorMacro("Error opening output file \"" << this->FileName << "\""); |
| 635 | this->SetErrorCode(vtkErrorCode::GetLastSystemError()); |
| 636 | vtkErrorMacro( |
| 637 | "Error code \"" << vtkErrorCode::GetStringFromErrorCode(this->GetErrorCode()) << "\""); |
| 638 | return 0; |
| 639 | } |
| 640 | this->Stream = this->OutFile; |
| 641 | |
| 642 | return 1; |
| 643 | } |
| 644 | |
| 645 | //------------------------------------------------------------------------------ |
| 646 | int vtkXMLWriter::OpenString() |
no outgoing calls
no test coverage detected