------------------------------------------------------------------------------
| 115 | |
| 116 | //------------------------------------------------------------------------------ |
| 117 | ostream* vtkGeoJSONWriter::OpenFile() |
| 118 | { |
| 119 | vtkDebugMacro(<< "Opening file\n"); |
| 120 | |
| 121 | ostream* fptr; |
| 122 | |
| 123 | if (!this->WriteToOutputString) |
| 124 | { |
| 125 | if (!this->FileName) |
| 126 | { |
| 127 | vtkErrorMacro(<< "No FileName specified! Can't write!"); |
| 128 | return nullptr; |
| 129 | } |
| 130 | |
| 131 | fptr = new vtksys::ofstream(this->FileName, ios::out); |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | // Get rid of any old output string. |
| 136 | if (this->OutputString) |
| 137 | { |
| 138 | delete[] this->OutputString; |
| 139 | this->OutputString = nullptr; |
| 140 | this->OutputStringLength = 0; |
| 141 | } |
| 142 | fptr = new std::ostringstream; |
| 143 | } |
| 144 | |
| 145 | if (fptr->fail()) |
| 146 | { |
| 147 | vtkErrorMacro(<< "Unable to open file: " << this->FileName); |
| 148 | delete fptr; |
| 149 | return nullptr; |
| 150 | } |
| 151 | |
| 152 | return fptr; |
| 153 | } |
| 154 | |
| 155 | //------------------------------------------------------------------------------ |
| 156 | void vtkGeoJSONWriter::CloseFile(ostream* fp) |