Deleting a Directory

From: Dylan Maxwell <Dylan.Maxwell_at_lightsource.ca>
Date: Tue, 23 Aug 2005 09:51:35 -0600


Dear Roottalk,

I want to completely remove a TDirectory from a TFile. For example try the following script (also attached).

{

   TFile *f = new TFile("test.root", "RECREATE");

   TDirectory *d = f->mkdir("newdir");

   cout << endl << endl << "The file now contains a directory on file and in memoroy..." << endl;    f->ls();

   f->Delete("newdir;*"); //delete directory

   cout << endl << endl << "The file now contains a directory in memory..." << endl;    f->ls();

   f->Delete("newdir");

   cout << endl << endl << "The file still contains a director in memeory..." << endl;    f->ls();

   delete d;    

   cout << endl << endl << "The directory has been completely removed." << endl;    f->ls();
}

Is this the expected behaviour when deleting a TDirectory from a TFile? I would think that TDirectory::Delete() should be able to completely remove a subdirectory? Maybe I've missed something?

I'm running ROOT v4.04 on Scientific Linux 4.1.

Thanks,
Dylan

Received on Tue Aug 23 2005 - 17:53:23 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:12 MET