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

Method OpenFile

IO/Geometry/vtkOpenFOAMReader.cxx:3134–3184  ·  view source on GitHub ↗

Attempt to open file (or file.gz) and read header

Source from the content-addressed store, hash-verified

3132
3133 // Attempt to open file (or file.gz) and read header
3134 bool OpenFile(const std::string& file, bool checkGzip = false)
3135 {
3136 this->ClearError(); // Discard any previous errors
3137 try
3138 {
3139 this->Superclass::Open(file);
3140 checkGzip = false;
3141 }
3142 catch (const vtkFoamError& err)
3143 {
3144 if (checkGzip)
3145 {
3146 // Avoid checking again if already ends_with(".gz")
3147 const auto len = file.length();
3148 if (len > 3 && file.compare(len - 3, std::string::npos, ".gz") == 0)
3149 {
3150 checkGzip = false;
3151 }
3152 }
3153 if (!checkGzip)
3154 {
3155 this->SetError(err);
3156 return false;
3157 }
3158 }
3159
3160 if (checkGzip)
3161 {
3162 try
3163 {
3164 this->Superclass::Open(file + ".gz");
3165 }
3166 catch (const vtkFoamError& err)
3167 {
3168 this->SetError(err);
3169 return false;
3170 }
3171 }
3172
3173 try
3174 {
3175 this->ReadHeader();
3176 }
3177 catch (const vtkFoamError& err)
3178 {
3179 this->Superclass::Close();
3180 this->SetError(err);
3181 return false;
3182 }
3183 return true;
3184 }
3185
3186 void CloseFile()
3187 {

Callers 4

OpenMethod · 0.95
OpenOrGzipMethod · 0.95
OpenCaseFileMethod · 0.95
OpenCaseFileOrGzipMethod · 0.95

Calls 5

ClearErrorMethod · 0.95
SetErrorMethod · 0.95
ReadHeaderMethod · 0.95
lengthMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected