rntviewer/rntviewer.cpp
2024-07-10 17:05:14 +02:00

44 lines
835 B
C++

#include "defer.hpp"
#include <ROOT/RNTupleReader.hxx>
#include <cstdio>
#include <sys/mman.h>
using namespace ROOT::Experimental;
static size_t file_size(FILE *f)
{
fseek(f, 0, SEEK_END);
size_t res = ftell(f);
fseek(f, 0, SEEK_SET);
return res;
}
int main(int argc, char **argv)
{
if (argc < 2) {
fprintf(stderr, "Usage: %s <ntuple_file.root>\n", argv[0]);
return 1;
}
// Open and map the file
const char *fname = argv[0];
FILE *file = fopen(fname, "rb");
defer { fclose(file); };
const int fd = fileno(file);
const size_t fsize = file_size(file);
void *fmem = mmap(0, fsize, PROT_READ, MAP_SHARED_VALIDATE, fd, 0);
if (!fmem) {
fprintf(stderr, "Failed to open file %s\n", fname);
return 1;
}
defer { munmap(fmem, fsize); };
// Get the RNTuple information
return 0;
}