Dear Rene Thank you for your comments. BTW, regarding DecodeNameCycle I realized too late that I can always call "gDirectory->DecodeNameCycle(..)" to get name and cycle. Best regards Christian Rene Brun wrote: > Hi Christian, > > On Sun, 6 Jan 2002, cstrato@EUnet.at wrote: > > > Dear Rene > > > > Thank you for the fast reply and especially for the implementation > > of TDirectory::FindObjectAny(). > > > > Please let me comment to your answers of my questions to see if my > > code has some flaws: > > > > 1, Constructor: As far as I understand "gDirectory->FindObject(name)" > > does only find an object if it is already in memory. So in order to > > check if a directory exists in a TFile stored on disk, I did: > > "key = fDir->GetKey(obj->GetName());" > > If (key != 0) then the directory does exist. Is this correct? > > > Correct > > > 2, RecursiveRemove: What I wanted to do is "fDir->Delete(obj)" in > > order to delete an object permanently from TFile on disk. > > I am not sure if "fDir->Delete(obj-GetName())" does delete the object > > permanently, since "obj-GetName()" does not return the namecycle, > > since the object is in memory? > > How can I delete an object permanently from a TFile on disk, when > > the object is loaded into memory already? > > Use TDirectory::Delete. Chhose one of the following options depending > what you want do do: > > void TDirectory::Delete(const char *namecycle) > // namecycle has the format name;cycle > // namecycle = "" same as namecycle ="T*" > // name = * means all > // cycle = * means all cycles (memory and keys) > // cycle = "" or cycle = 9999 ==> apply to a memory object > // When name=* use T* to delete subdirectories also > // > // To delete one directory, you must specify the directory cycle, > // eg. file.Delete("dir1;1"); > // > // examples: > // foo : delete object named foo in memory > // foo* : delete all objects with a name starting with foo > // foo;1 : delete cycle 1 of foo on file > // foo;* : delete all cycles of foo on file and also from memory > // *;2 : delete all objects on file having the cycle 2 > // *;* : delete all objects from memory and file > // T*;* : delete all objects from memory and file and all > subdirectories > > > > > 5, EncodeNameCycle: I need to get "key = fDir->GetKey(name,cycle);", > > so I have written my own function to extract name and cycle, but I > > thought it would be easier if TObject would already contain this > > possibility. > > > With the new functions FindKey and FindKeyAny, you do not need to call > EncodeNameCycle. You can do directly, eg: > mydir->FindKey("blabla;1"); > > Rene Brun >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET