rntviewer/src/rntuple.cpp

39 lines
1.1 KiB
C++
Raw Normal View History

2024-07-11 12:00:43 +00:00
internal
String8 rntuple_description(Arena *arena, const RNTuple &anchor)
{
String8 desc = push_str8f(arena, "version %u.%u.%u.%u",
anchor.GetVersionEpoch(),
anchor.GetVersionMajor(),
anchor.GetVersionMinor(),
anchor.GetVersionPatch());
return desc;
}
internal
2024-07-11 12:27:19 +00:00
RNTuple_Info get_rntuple_info(Arena *arena, const char *fname, const char *ntpl_name)
2024-07-11 12:00:43 +00:00
{
2024-07-11 12:27:19 +00:00
RNTuple_Info info = {};
2024-07-11 12:00:43 +00:00
// Open the TFile
TFile *tfile = TFile::Open(fname, "READ");
if (!tfile) {
fprintf(stderr, "Failed to open TFile.\n");
return info;
}
defer { delete tfile; };
// Get the RNTuple information
const RNTuple *anchor = tfile->Get<RNTuple>(ntpl_name);
if (anchor) {
2024-07-11 12:27:19 +00:00
info.anchor = *anchor;
info.header.start = anchor->GetSeekHeader();
info.header.len = anchor->GetNBytesHeader();
info.footer.start = anchor->GetSeekFooter();
info.footer.len = anchor->GetNBytesFooter();
2024-07-11 12:00:43 +00:00
} else {
fprintf(stderr, "RNTuple '%s' not found in %s.\n", ntpl_name, fname);
}
return info;
}