MCPcopy Create free account
hub / github.com/Kitware/VTK / OpenVTKFile

Method OpenVTKFile

IO/XML/vtkXMLReader.cxx:317–363  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

315
316//------------------------------------------------------------------------------
317int vtkXMLReader::OpenVTKFile()
318{
319 if (this->FileStream)
320 {
321 vtkErrorMacro("File already open.");
322 return 1;
323 }
324
325 if (!this->Stream && !this->FileName)
326 {
327 vtkErrorMacro("File name not specified");
328 return 0;
329 }
330
331 if (this->Stream)
332 {
333 // Use user-provided stream.
334 return 1;
335 }
336
337 // Need to open a file. First make sure it exists. This prevents
338 // an empty file from being created on older compilers.
339 vtksys::SystemTools::Stat_t fs;
340 if (vtksys::SystemTools::Stat(this->FileName, &fs) != 0)
341 {
342 vtkErrorMacro("Error opening file " << this->FileName);
343 return 0;
344 }
345
346 std::ios_base::openmode mode = ios::in;
347#ifdef _WIN32
348 mode |= ios::binary;
349#endif
350 this->FileStream = new vtksys::ifstream(this->FileName, mode);
351 if (!this->FileStream || !(*this->FileStream))
352 {
353 vtkErrorMacro("Error opening file " << this->FileName);
354 delete this->FileStream;
355 this->FileStream = nullptr;
356 return 0;
357 }
358
359 // Use the file stream.
360 this->Stream = this->FileStream;
361
362 return 1;
363}
364
365//------------------------------------------------------------------------------
366int vtkXMLReader::OpenVTKString()

Callers 3

OpenStreamMethod · 0.95
WriteDataMethod · 0.45
WriteDataMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected