Re: [ROOT] rfio file - how to check if it is already opened

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Thu Feb 14 2002 - 14:52:54 MET


Hi Jiri,

  if you just try to see if the file has been opened you can just use:

TFile *n =
(TFile*)gROOT->GetListOfFiles()->FindObject("rfio:/castor/cern.ch/user/r/rdm/hsimple.root")

and there will be no cd() issued.

Cheers, Fons.



On Thu, 2002-02-14 at 14:46, Jiri Chudoba wrote:
> Hi Fons,
> 
> I want to test if file is opened or not. The code works, because I get
> a null pointer to TFile, but I would like to get rid of that error 
> message because it looks like something is going wrong.
> 
>             Thanks, cheers,
>                                Jiri.
> 
> *************************************************************************
> * E-mail address:  Jiri.Chudoba@cern.ch                                 *
> * WWW Homepage  :  http://delphiwww.troja.mff.cuni.cz/chudoba/          *
> * Telephone     :  +41 22 76 72288                                      *
> * Fax           :  +41 22 76 79480                                      *
> *************************************************************************
> 
> 
> On 14 Feb 2002, Fons Rademakers wrote:
> 
> > Hi Jiri,
> > 
> >   for me this fails only when the file has not been opened. See:
> > 
> > root [0] TFile *n =
> > (TFile*)gROOT->FindObject("rfio:/castor/cern.ch/user/r/rdm/hsimple.root")
> > Error in <TROOT::cd>: No such file
> > rfio:/castor/cern.ch/user/r/rdm/hsimple.root
> > root [1] TFile *f =
> > TFile::Open("rfio:/castor/cern.ch/user/r/rdm/hsimple.root")
> > root [2] TFile *n =
> > (TFile*)gROOT->FindObject("rfio:/castor/cern.ch/user/r/rdm/hsimple.root")
> > root [3] n
> > (class TFile*)0x86e0748
> > 
> > 
> > Cheers, Fons.
> > 
> > 
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET