Dear Rooters

I am just reading the new release notes of root 5.12/02 with warnings regarding io directory.

The ROOT documents have always compared TFile with a UNIX directory, where you can create
directories and subdirectories. Since TDirectory is now declared to be an abstract class,
does this mean that all applications creating subdirectories in TFile will break and be
backward incompatible???

For example, in my application I am creating a directory in the following way:

      TDirectory *dir = fFile->GetDirectory(setname);
      if (!dir) fFile->mkdir(setname, fType);

I suppose this code will break and be backward incompatible. Is this correct?

Furthermore, I have often the follwing code:

   TDirectory *savedir = gDirectory;

   //do something


This will break, too??

Maybe, calling the abstract directory “TBaseDirectory” and deriving “TDirectory” from
"TBaseDirectory" would have avoided these problems?

Best regards

Wrong! The code you show will continue to work.
Only in case you have a call like “new TDirectory”, you have to replace it
by “new TDirectoryFile”. Same for TBuffer.


Dear Rene

Thank you for this fast clarification, now I understand what the release notes say:
Only, if you create your own directory by calling “new TDirectory”, you have to change your code.

Best regards

Hi Christian,

Independently of the changes that were recently made, you should consider replacing (or using in future code):

TDirectory::TContext ctxt(0); // or directory you want to cd toinstead of using your savedir pattern. This new syntax insure that the savedir->cd() is always done when you exit the scope (aka you will never forgot to add it when you add a new return statement to your functions.


Dear Philippe
Thank you for this tip.