Re: [ROOT] Cannot set file->SetName()

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Aug 07 2002 - 20:08:52 MEST


Christian,

You cannot change the name of a TFile once the physical file has been
created by the constructor.

Rene Brun

On Wed, 7 Aug 2002, cstrato wrote:

> Dear Rene
> 
> Probably, I am doing something wrong, but it is not possible
> to change the name of a root file.
> 
> I have the following class:
> MyClass: public TNamed {
> private:
>     TFile *fFileA;
>     TFile *fFileB;
> public:
>     void CreateFiles();
> }
> 
> The following version works fine and writes both files to disk:
> void MyClass::CreateFiles()
> {
>     fFileA = new TFile("Afile.root","RECREATE");
>     fFileB = new TFile("Bfile.root","RECREATE");
> }
> 
> However, the following version stores only one file "Afile.root":
> void MyClass::CreateFiles()
> {
>     fFileB = new TFile("Afile.root","RECREATE");
>     fFileB->SetName("Bfile.root");
>     fFileA = new TFile("Afile.root","RECREATE");
> }
> 
> Although both files are available in memory, and the filenames are
> correct (as TBrowser shows), once I call the destructor of MyClass,
> only  "Afile.root" is finally written to disk.
> Is there a way to rename a TFile?
> 
> Thank you in advance for your help
> 
> Best regards
> Christian
> _._._._._._._._._._._._._._._._._
> C.h.r.i.s.t.i.a.n S.t.r.a.t.o.w.a
> V.i.e.n.n.a         A.u.s.t.r.i.a
> _._._._._._._._._._._._._._._._._
> 
> 



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