diff --git a/io/io/src/TFile.cxx b/io/io/src/TFile.cxx index 4d71c78283592..bc94d64afc7ab 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -362,6 +362,14 @@ TFile::TFile() : TDirectoryFile(), fCompress(ROOT::RCompressionSetting::EAlgorit /// ~~~{.cpp} /// TFile *f = TFile::Open("tmpname.root?reproducible=fixedname","RECREATE","File title"); /// ~~~ +/// +/// To check for the health status of a TFile and detect corruption, you can perform the following checks after opening it: +/// ~~~{.cpp} +/// std::unique_ptr f{TFile::Open("name.root", "READ")}; +/// auto bad_input = (f == nullptr); // File could not be open, e.g. if input url was incorrect or incorrect permissions. +/// auto bad_initalization = (f && f->IsZombie()); // something went wrong in the constructor, for example when TFile is corrupt +/// auto bad_storage = (f && f->TestBit(TFile::kRecovered)); // The TFile had to run the recovery mechanism when opening the file; often due to the file being incorrectly closed. +/// ~~~ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t compress) : TDirectoryFile(), fCompress(compress), fUrl(fname1,kTRUE)