TFile::ls() subdirectories recursively

I call

TFile *f = TFile::Open("file.root")
f -> ls()

and get

TFile**		file.root	
 TFile*		file.root	
  KEY: TDirectoryFile	dir1;1	dir1

To list the contents of the directory dir1 I need to call separately

f -> GetDirectory("dir1") -> ls()

How can I recursively list all objects in subdirectories?

Try to call f->ReadAll() before f->ls():

root [1] f->ls()
TFile**         small.root
 TFile*         small.root
  KEY: TDirectoryFile   something;1     something
  KEY: TProcessID       ProcessID0;1    961dc7ef-5ff3-11e7-8053-8cbb8d80beef
root [2] f->ReadAll()
root [3] f->ls()
TFile**         small.root
 TFile*         small.root
  TDirectoryFile*               something       something
   KEY: TTree   T;1     An example of a ROOT tree
  KEY: TDirectoryFile   something;1     something
  KEY: TProcessID       ProcessID0;1    961dc7ef-5ff3-11e7-8053-8cbb8d80beef
root [4]
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.