navigate to the c:\\scripts Solution #include \"TFile.h\" #include \"TKey.h\" #i
ID: 3645998 • Letter: N
Question
navigate to the c:scriptsExplanation / Answer
#include "TFile.h" #include "TKey.h" #include "TMacro.h" Int_t nlines = 0; Int_t nfiles = 0; Int_t ndirs = 0; Int_t nh = 0; Int_t nc = 0; Int_t nC = 0; Int_t npy = 0; void readdir(TDirectory *dir) { ndirs++; TDirectory *dirsav = gDirectory; TIter next(dir->GetListOfKeys()); TKey *key; while ((key = (TKey*)next())) { if (key->IsFolder()) { dir->cd(key->GetName()); TDirectory *subdir = gDirectory; readdir(subdir); dirsav->cd(); continue; } TMacro *macro = (TMacro*)key->ReadObj(); nfiles++; nlines += macro->GetListOfLines()->GetEntries(); if (strstr(key->GetName(),".h")) nh++; if (strstr(key->GetName(),".c")) nc++; if (strstr(key->GetName(),".C")) nC++; if (strstr(key->GetName(),".py")) npy++; delete macro; } } void readCode() { TFile *f = new TFile("code.root"); if (f->IsZombie()) { printf("File code.root does not exist. Run tutorial importCode.C first "); return; } printf("Reading file ==> code.root "); printf("File size in bytes = %lld ",f->GetEND()); printf("File compression factor = %g ",f->GetCompressionFactor()); readdir(f); printf("Number of sub-dirs = %d ",ndirs); printf("Number of macro files = %d ",nfiles); printf("Number of lines in mac = %d ",nlines); printf("Number of cxx,c,cc files = %d ",nc); printf("Number of C files = %d ",nC); printf("Number of Python files = %d ",npy); } readCode.C:1 readCode.C:2 readCode.C:3 readCode.C:4 readCode.C:5 readCode.C:6 readCode.C:7 readCode.C:8 readCode.C:9 readCode.C:10 readCode.C:11 readCode.C:12 readCode.C:13 readCode.C:14 readCode.C:15 readCode.C:16 readCode.C:17 readCode.C:18 readCode.C:19 readCode.C:20 readCode.C:21 readCode.C:22 readCode.C:23 readCode.C:24 readCode.C:25 readCode.C:26 readCode.C:27 readCode.C:28 readCode.C:29 readCode.C:30 readCode.C:31 readCode.C:32 readCode.C:33 readCode.C:34 readCode.C:35 readCode.C:36 readCode.C:37 readCode.C:38 readCode.C:39 readCode.C:40 readCode.C:41 readCode.C:42 readCode.C:43 readCode.C:44 readCode.C:45 readCode.C:46 readCode.C:47 readCode.C:48 readCode.C:49 readCode.C:50 readCode.C:51 readCode.C:52 readCode.C:53 readCode.C:54 readCode.C:55 readCode.C:56 readCode.C:57 readCode.C:58 readCode.C:59 readCode.C:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.