00001 #include "TFile.h"
00002 #include "TSystem.h"
00003 #include "TMacro.h"
00004
00005 void importdir(const char *dirname) {
00006
00007
00008
00009
00010
00011
00012
00013 char *slash = (char*)strrchr(dirname,'/');
00014 char *locdir;
00015 if (slash) locdir = slash+1;
00016 else locdir = (char*)dirname;
00017 printf("processing dir %s\n",dirname);
00018 TDirectory *savdir = gDirectory;
00019 TDirectory *adir = savdir->mkdir(locdir);
00020 adir->cd();
00021 void *dirp = gSystem->OpenDirectory(dirname);
00022 if (!dirp) return;
00023 char *direntry;
00024 Long_t id, size,flags,modtime;
00025
00026 while ((direntry=(char*)gSystem->GetDirEntry(dirp))) {
00027 TString afile = Form("%s/%s",dirname,direntry);
00028 gSystem->GetPathInfo(afile,&id,&size,&flags,&modtime);
00029 if (direntry[0] == '.') continue;
00030 if (!strcmp(direntry,"CVS")) continue;
00031 if (!strcmp(direntry,"htmldoc")) continue;
00032 if (strstr(dirname,"root/include")) continue;
00033 if (strstr(direntry,"G__")) continue;
00034 if (strstr(direntry,".c") ||
00035 strstr(direntry,".h") ||
00036 strstr(direntry,".dat") ||
00037 strstr(direntry,".py") ||
00038 strstr(direntry,".C")) {
00039 TMacro *m = new TMacro(afile);
00040 m->Write(direntry);
00041 delete m;
00042 } else {
00043 if (flags != 3) continue;
00044
00045 importdir(afile);
00046 }
00047 }
00048 gSystem->FreeDirectory(dirp);
00049 savdir->cd();
00050 }
00051 void importCode() {
00052 TFile *f = new TFile("code.root","recreate");
00053 importdir("../../../root");
00054 delete f;
00055 }