TFile cd() warning suppression?

hi all

i have a program that opens a file and does a tentative cd to a directory in that file, say:

TFile* file = TFile::Open(“file.root”);
file->cd();
if( file->cd(“test”) ) {
// blabla
}

point is: i want to perform some actions only if i find a directory called ‘test’. if i don’t find it, no big deal, program goes ahead as usual.

this works, but there’s this annoying feature that i get a warning message on the screen:

Error in TFile::cd: Unknown directory test

in case the directory doesn’t exist. is there a way to suppress this message, by any chance?

thanks a lot
f

Try like this:

TFile* file = TFile::Open("file.root"); file->cd(); if ( file->GetDirectory("test") ) { file->cd("test"); // blabla }
Cheers, Bertrand.

great! works!

thanks
f