Hi, Valeriy, thank you for reply. I wrote your solution as a function in rootalias.C with a little modification to avoid SegV when no file is opened. void lf() { TIter next(gROOT->GetListOfGlobals()); TGlobal *global; while ((global=(TGlobal*)next())) { TString type = global->GetTypeName(); if (type=="TFile") { TFile *file = (TFile*)gInterpreter->Calc(global->GetName()); if (file && file->IsOpen()) printf("%s: %s\n", global->GetName(),file->GetName()); } } } But, unfortunately, this does not always work properly. ******************************************* * * * W E L C O M E to R O O T * * * * Version 3.05/05 15 May 2003 * * * * You are welcome to visit our Web site * * http://root.cern.ch * * * ******************************************* FreeType Engine v2.1.3 used to render TrueType fonts. Compiled for linux with thread support. CINT/ROOT C/C++ Interpreter version 5.15.86, Apr 29 2003 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. root [0] TFile f("foo.root") root [1] lf() gFile: foo.root f: foo.root root [2] f.Close() root [3] lf() root [4] lf() root [5] lf() root [6] TFile f("foo.root") root [7] lf() gFile: foo.root f: foo.root root [8] TFile f2("bar.root") root [9] lf() gFile: bar.root f: foo.root root [10] "f2" is not listed now. Is this an unreasonable demand? Best regards, Satoru Kameoka From: "Valeriy Onuchin" <Valeri.Onoutchine@cern.ch> Subject: Re: [ROOT] How to list files Date: Tue, 29 Jul 2003 15:52:26 +0200 Message-ID: <066001c355d8$a50ebfd0$c1848a89@cern.ch> > Hi Satoru KAMEOKA, > > TIter next(gROOT->GetListOfGlobals()); > TGlobal *global; > TFile *file; > while ((global=(TGlobal*)next())) { > TString type; > type = global->GetTypeName(); > if (type=="TFile") { > file = (TFile*)gInterpreter->Calc(global->GetName()); > printf("%s: %s\n", global->GetName(),file->GetName()); > } > } > > HTH. Regards. Valeriy > > > Hi, Valeriy, > > Thank you for reply. > > The way you taught surely shows file name and its contents, but not > > associated object "instance name". > > > > What I hope is, when some files are opened, > > root[] TFile f1("foo.root") > > root[] TFile f2("bar.root") > > root[] TFile f3("hoge.root") > > > > some command can show the list as below. > > root[] some_command > > f1 "foo.root" > > f2 "bar.root" > > f3 "hoge.root" > > > > Yes, I can understand that we can easily retrieve TFile object pointer > > from file name even if I've fogotten the instance names(f1, f2, f3). > > But I feel such command would be useful, because I sometimes attempt > > to use already connected TFile object by mistake and cause > > segmentation violation, like > > root[] TFile f("A_file.root") > > root[] TFile f("Another_file.root") > > > > Anyway, thanks a lot. > > > > Best regards, > > S.Kameoka > > > > From: "Valeriy Onuchin" <Valeri.Onoutchine@cern.ch> > > Subject: Re: [ROOT] How to list files > > Date: Mon, 28 Jul 2003 17:07:52 +0200 > > Message-ID: <028001c3551a$04c250a0$c1848a89@cern.ch> > > > > > Hi Satoru, > > > > > > TIter next(gROOT->GetListOfFiles()); > > > TObject *obj; > > > while ((obj=next())) obj->ls(); > > > > > > HTH. Regards. Valeriy > > > > > > > Dear ROOT developers and users, > > > > > > > > is there any way to list currently opened files? > > > > I found gROOT->GetListOfFiles()->Print() prints file names, > > > > but I want to know also associated TFile object instance names > > > > as "ldir //" command of PAW shows file name and LUN. > > > > > > > > > > > > Best regards, > > > > Satoru Kameoka > > > > > > > > > > > > > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET