00001
00002
00003
00004
00005
00006 #include "TFile.h"
00007 #include "TKey.h"
00008 #include "TMacro.h"
00009
00010 Int_t nlines = 0;
00011 Int_t nfiles = 0;
00012 Int_t ndirs = 0;
00013 Int_t nh = 0;
00014 Int_t nc = 0;
00015 Int_t nC = 0;
00016 Int_t npy = 0;
00017 void readdir(TDirectory *dir) {
00018 ndirs++;
00019 TDirectory *dirsav = gDirectory;
00020 TIter next(dir->GetListOfKeys());
00021 TKey *key;
00022 while ((key = (TKey*)next())) {
00023 if (key->IsFolder()) {
00024 dir->cd(key->GetName());
00025 TDirectory *subdir = gDirectory;
00026 readdir(subdir);
00027 dirsav->cd();
00028 continue;
00029 }
00030 TMacro *macro = (TMacro*)key->ReadObj();
00031 nfiles++;
00032 nlines += macro->GetListOfLines()->GetEntries();
00033 if (strstr(key->GetName(),".h")) nh++;
00034 if (strstr(key->GetName(),".c")) nc++;
00035 if (strstr(key->GetName(),".C")) nC++;
00036 if (strstr(key->GetName(),".py")) npy++;
00037 delete macro;
00038 }
00039 }
00040
00041
00042 void readCode() {
00043 TFile *f = new TFile("code.root");
00044 if (f->IsZombie()) {
00045 printf("File code.root does not exist. Run tutorial importCode.C first\n");
00046 return;
00047 }
00048 printf("Reading file ==> code.root\n");
00049 printf("File size in bytes = %lld\n",f->GetEND());
00050 printf("File compression factor = %g\n",f->GetCompressionFactor());
00051
00052 readdir(f);
00053
00054 printf("Number of sub-dirs = %d\n",ndirs);
00055 printf("Number of macro files = %d\n",nfiles);
00056 printf("Number of lines in mac = %d\n",nlines);
00057 printf("Number of cxx,c,cc files = %d\n",nc);
00058 printf("Number of C files = %d\n",nC);
00059 printf("Number of Python files = %d\n",npy);
00060 }