Re: problem updating a root file

From: Nikolay I. Root (nroot@inp.nsk.su)
Date: Tue Jul 14 1998 - 18:58:11 MEST


Hi,Hajo.
Yes, the problem with updating directories within TFile exists.
(at least on Linux,RedHat-4.2, ROOT version 2.00/09)

file.Map()  shows that object "eva" writing to file, but
directory, that contains "eva" not updated !
To fix problem you need read object "dir1" expicitly befor updating.
The modified version of your macro works (see below).

Best wishes, Nikolay.

On Tue, 14 Jul 1998 mayer@ik1.fzk.de wrote:

> Dear rooters.
> 
> 
> Please let me repost my problem, because it is not due to using or not using
> CINT extensions, and I hav'nt get an answer yet.
> 
> Once I've closed a root file, i'm not able to write again
> into an already created directory. The newly written object appears
> in memory but not on disk. After closing and reopening the file, it is lost.
> ALso I cant delete an object after reopening the file. This also
> happens with compiled code. This macro is only an example, because it
> behaves in the same manner!
> 
> {
>    gROOT.Reset();
>    TFile file("test.root","recreate");
>    gDirectory->mkdir("dir1");
>    gDirectory->cd("dir1");
>    named = new TNamed("amo","amo");
>    named->Write("amo");
>    gDirectory->ls();
>    file->Write();
>    file->Close();
>    printf("------file closed-------\n");
> 
>    TFile file("test.root","update");
     TDirecrory *d = (TDirectory*)file.Get("dir1");
   // gDirectory->cd("dir1");
>    named = new TNamed("eva","eva");
>    named->Write("eva");
>    gDirectory->ls();
>    file->Write();
>    file->Close();
>    printf("------file closed-------\n");
> 
>    TFile file("test.root","update");
>    gDirectory->cd("dir1");
>    gDirectory->ls();
> }
> 
 and this is the output:
 

root [0] .x exam.C 
TDirectory*             dir1    dir1
 KEY: TNamed    amo;1   amo
------file closed-------
TFile Writing Name=test.root Title=
TFile**         test.root
 TFile*         test.root
  TDirectory*           dir1    dir1
   KEY: TNamed  amo;1   amo
  KEY: TDirectory       dir1;1  dir1
  KEY: TNamed   eva;1   eva
------file closed-------
TFile**         test.root
 TFile*         test.root
  TDirectory*           dir1    dir1
   KEY: TNamed  amo;1   amo
  KEY: TDirectory       dir1;1  dir1
  KEY: TNamed   eva;1   eva

                               Nikolay Root
                               BINP, Novosibirsk
                               email : nroot@inp.nsk.su



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:35 MET