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

Method open

IO/Geometry/vtkTecplotReader.cxx:78–108  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

76
77//------------------------------------------------------------------------------
78bool FileStreamReader::open(const char* fileName)
79{
80 if (!this->Open)
81 {
82 this->FileName = std::string(fileName);
83 // zlib handles both compressed and uncompressed file
84 // we just have peak into the file and see if it has the magic
85 // flags or not
86 unsigned char magic[2];
87 FILE* ff = vtksys::SystemTools::Fopen(fileName, "rb");
88 size_t count = fread(magic, 1, 2, ff);
89 fclose(ff);
90
91 // only continue if fread succeeded
92 if (count == 2)
93 {
94 const char* mode = (magic[0] == 0x1f && magic[1] == 0x8b) ? "rb" : "r";
95#if defined(_WIN32)
96 std::wstring fileNameWide = vtksys::Encoding::ToWide(fileName);
97 this->file = gzopen_w(fileNameWide.c_str(), mode);
98#else
99 this->file = gzopen(fileName, mode);
100#endif
101
102 this->Eof = (this->file == nullptr);
103 this->Open = (this->file != nullptr);
104 this->Pos = BUFF_SIZE;
105 }
106 }
107 return this->Open;
108}
109//------------------------------------------------------------------------------
110int FileStreamReader::get()
111{

Callers 7

rewindMethod · 0.95
WriteDataMethod · 0.45
GetDataArraysListMethod · 0.45
ReadFileMethod · 0.45
SetupBladeDataMethod · 0.45
CanParseFileMethod · 0.45

Calls 4

gzopen_wFunction · 0.85
gzopenFunction · 0.85
stringClass · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected