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

Method UpdateMetadata

IO/CellGrid/vtkCompositeCellGridReader.cxx:215–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213};
214
215bool vtkCompositeCellGridReader::UpdateMetadata()
216{
217 if (this->MetadataTime.GetMTime() >= this->GetMTime())
218 {
219 return false;
220 }
221
222 MetadataGuard meta(this);
223 if (!this->FileName)
224 { // Make sure we have a file to read.
225 return false;
226 }
227
228 // All files listed in this->FileName must be absolute or are assumed
229 // relative to the location of this->FileName. Get the absolute path
230 // for this->FileName so we can turn relative paths into absolute ones.
231 std::string err;
232 auto realFileName = vtksys::SystemTools::GetRealPath(this->FileName, &err);
233 if (!err.empty())
234 {
235 vtkErrorMacro("Could not determine location of \"" << this->FileName << "\".");
236 return false;
237 }
238 std::vector<std::string> pathParts;
239 vtksys::SystemTools::SplitPath(realFileName, pathParts);
240 if (pathParts.size() < 2)
241 {
242 vtkErrorMacro("Could not determine parent directory of \"" << this->FileName << "\".");
243 return false;
244 }
245 pathParts.pop_back(); // Drop the filename so we are left with the parent directory.
246
247 // Check the file's validity.
248 std::ifstream file(this->FileName);
249 if (!file.good())
250 {
251 vtkErrorMacro("Cannot read file \"" << this->FileName << "\".");
252 return false;
253 }
254
255 // Read the file into nlohmann json.
256 nlohmann::json jj;
257 try
258 {
259 jj = nlohmann::json::parse(file);
260 }
261 catch (...)
262 {
263 vtkErrorMacro("Cannot parse file \"" << this->FileName << "\".");
264 return false;
265 }
266
267 vtkLogScopeF(TRACE, "UpdateMetadata");
268 bool isComposite = true;
269 auto jtype = jj.find("data-type");
270 if (jtype == jj.end())
271 {
272 vtkErrorMacro("Data type is missing.");

Callers 1

ReadMetaDataMethod · 0.95

Calls 15

GetMTimeMethod · 0.95
GetCellTypeSelectionMethod · 0.95
pop_backMethod · 0.80
CellTypeArrayMethod · 0.80
DisableArrayMethod · 0.80
GetCellAttributeByIdMethod · 0.80
RemoveArrayByNameMethod · 0.80
parseFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected