diff --git a/base/inc/LinkDef1.h b/base/inc/LinkDef1.h index 5b0208ebdad6575725318408b48877f10343dbbf..67abceb7ecc1db4a5296c25ace8e8ac20414f559 100644 --- a/base/inc/LinkDef1.h +++ b/base/inc/LinkDef1.h @@ -1,4 +1,4 @@ -/* @(#)root/base:$Name: $:$Id: LinkDef1.h,v 1.41 2006/11/25 09:07:59 brun Exp $ */ +/* @(#)root/base:$Name: $:$Id: LinkDef1.h,v 1.42 2007/01/19 16:47:59 brun Exp $ */ /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * @@ -139,7 +139,8 @@ #pragma link C++ class TControlBarImp+; #pragma link C++ class TInspectorImp+; #pragma link C++ class TDatime-; -#pragma link C++ class TDirectory-; +#pragma link C++ class TDirectory; +#pragma link C++ class TDirectoryFile-; #pragma link C++ class TEnv+; #pragma link C++ class TEnvRec+; #pragma link C++ class TFile-; diff --git a/base/inc/TDirectory.h b/base/inc/TDirectory.h index 7e382270427e24e3c4238dad0691aac48c97f415..baca6fcb8f96c2698b987ab2827965b5b8afa869 100644 --- a/base/inc/TDirectory.h +++ b/base/inc/TDirectory.h @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TDirectory.h,v 1.36 2006/05/23 04:47:35 brun Exp $ +// @(#)root/base:$Name: $:$Id: TDirectory.h,v 1.37 2006/06/20 18:17:34 pcanal Exp $ // Author: Rene Brun 28/11/94 /************************************************************************* @@ -43,35 +43,21 @@ R__EXTERN TDirectory *gDirectory; class TDirectory : public TNamed { protected: - Bool_t fModified; //true if directory has been modified - Bool_t fWritable; //true if directory is writable - TDatime fDatimeC; //Date and time when directory is created - TDatime fDatimeM; //Date and time of last modification - Int_t fNbytesKeys; //Number of bytes for the keys - Int_t fNbytesName; //Number of bytes in TNamed at creation time - Int_t fBufferSize; //Default buffer size to create new TKeys - Long64_t fSeekDir; //Location of directory on file - Long64_t fSeekParent; //Location of parent directory on file - Long64_t fSeekKeys; //Location of Keys record on file - TFile *fFile; //pointer to current file in memory TObject *fMother; //pointer to mother of the directory - TList *fList; //Pointer to objects list in memory - TList *fKeys; //Pointer to keys list in memory + TList *fList; //List of objects in memory TUUID fUUID; //Unique identifier - TString fPathBuffer; //!Buffer for GetPath() function - + TString fPathBuffer; //!Buffer for GetPath() function + Bool_t cd1(const char *path); static Bool_t Cd1(const char *path); void FillFullPath(TString& buf) const; -private: +protected: TDirectory(const TDirectory &directory); //Directories cannot be copied void operator=(const TDirectory &); //Directorise cannot be copied public: - // TDirectory status bits - enum { kCloseDirectory = BIT(7) }; /** @class Context * @@ -111,10 +97,10 @@ public: TDirectory(const char *name, const char *title, Option_t *option="", TDirectory* motherDir = 0); virtual ~TDirectory(); virtual void Append(TObject *obj); - void Add(TObject *obj) { Append(obj); } - Int_t AppendKey(TKey *key); + virtual void Add(TObject *obj) { Append(obj); } + virtual Int_t AppendKey(TKey *) {return 0;} virtual void Browse(TBrowser *b); - void Build(TFile* motherFile = 0, TDirectory* motherDir = 0); + virtual void Build(TFile* motherFile = 0, TDirectory* motherDir = 0); virtual void Clear(Option_t *option=""); virtual void Close(Option_t *option=""); virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); } @@ -122,9 +108,8 @@ public: virtual void DeleteAll(Option_t *option=""); virtual void Delete(const char *namecycle=""); virtual void Draw(Option_t *option=""); - virtual void FillBuffer(char *&buffer); - virtual TKey *FindKey(const char *keyname) const; - virtual TKey *FindKeyAny(const char *keyname) const; + virtual TKey *FindKey(const char * /*keyname*/) const {return 0;} + virtual TKey *FindKeyAny(const char * /*keyname*/) const {return 0;} virtual TObject *FindObject(const char *name) const; virtual TObject *FindObject(const TObject *obj) const; virtual TObject *FindObjectAny(const char *name) const; @@ -137,62 +122,60 @@ public: virtual void *GetObjectChecked(const char *namecycle, const char* classname); virtual void *GetObjectChecked(const char *namecycle, const TClass* cl); virtual void *GetObjectUnchecked(const char *namecycle); - virtual Int_t GetBufferSize() const; - const TDatime &GetCreationDate() const { return fDatimeC; } - virtual TFile *GetFile() const { return fFile; } - virtual TKey *GetKey(const char *name, Short_t cycle=9999) const; + virtual Int_t GetBufferSize() const {return 0;} + virtual TFile *GetFile() const { return 0; } + virtual TKey *GetKey(const char * /*name */, Short_t /* cycle */=9999) const {return 0;} virtual TList *GetList() const { return fList; } - virtual TList *GetListOfKeys() const { return fKeys; } - const TDatime &GetModificationDate() const { return fDatimeM; } - TObject *GetMother() const { return fMother; } - TDirectory *GetMotherDir() const { return fMother==0 ? 0 : dynamic_cast<TDirectory*>(fMother); } - virtual Int_t GetNbytesKeys() const { return fNbytesKeys; } - virtual Int_t GetNkeys() const { return fKeys->GetSize(); } - virtual Long64_t GetSeekDir() const { return fSeekDir; } - virtual Long64_t GetSeekParent() const { return fSeekParent; } - virtual Long64_t GetSeekKeys() const { return fSeekKeys; } + virtual TList *GetListOfKeys() const { return 0; } + virtual TObject *GetMother() const { return fMother; } + virtual TDirectory *GetMotherDir() const { return fMother==0 ? 0 : dynamic_cast<TDirectory*>(fMother); } + virtual Int_t GetNbytesKeys() const { return 0; } + virtual Int_t GetNkeys() const { return 0; } + virtual Long64_t GetSeekDir() const { return 0; } + virtual Long64_t GetSeekParent() const { return 0; } + virtual Long64_t GetSeekKeys() const { return 0; } virtual const char *GetPathStatic() const; virtual const char *GetPath() const; TUUID GetUUID() const {return fUUID;} - Bool_t IsFolder() const { return kTRUE; } - Bool_t IsModified() const { return fModified; } - Bool_t IsWritable() const { return fWritable; } + virtual Bool_t IsFolder() const { return kTRUE; } + virtual Bool_t IsModified() const { return kFALSE; } + virtual Bool_t IsWritable() const { return kFALSE; } virtual void ls(Option_t *option="") const; virtual TDirectory *mkdir(const char *name, const char *title=""); virtual void Paint(Option_t *option=""); virtual void Print(Option_t *option="") const; - virtual void Purge(Short_t nkeep=1); + virtual void Purge(Short_t /*nkeep*/=1) {} virtual void pwd() const; - virtual void ReadAll(Option_t *option=""); - virtual Int_t ReadKeys(); + virtual void ReadAll(Option_t * /*option*/="") {} + virtual Int_t ReadKeys() {return 0;} virtual void RecursiveRemove(TObject *obj); virtual void rmdir(const char *name); - virtual void Save(); - virtual void SaveSelf(Bool_t force = kFALSE); - virtual void SetBufferSize(Int_t bufsize); - void SetModified() {fModified = kTRUE;} - void SetMother(const TObject *mother) {fMother = (TObject*)mother;} + virtual void Save() {} + virtual void SaveSelf(Bool_t /*force*/ = kFALSE) {} + virtual void SetBufferSize(Int_t /* bufsize */) {} + virtual void SetModified() {} + virtual void SetMother(const TObject *mother) {fMother = (TObject*)mother;} virtual void SetName(const char* newname); - void SetSeekDir(Long64_t v) { fSeekDir = v; } - void SetWritable(Bool_t writable=kTRUE); - virtual Int_t Sizeof() const; - virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0); - virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0) const ; - virtual Int_t WriteTObject(const TObject *obj, const char *name=0, Option_t *option=""); + virtual void SetSeekDir(Long64_t) {} + virtual void SetWritable(Bool_t) {} + virtual Int_t Sizeof() const {return 0;} + virtual Int_t Write(const char * /*name*/=0, Int_t /*opt*/=0, Int_t /*bufsiz*/=0){return 0;} + virtual Int_t Write(const char * /*name*/=0, Int_t /*opt*/=0, Int_t /*bufsiz*/=0) const {return 0;} + virtual Int_t WriteTObject(const TObject *, const char * /*name*/=0, Option_t * /*option*/="") {return 0;} template <class T> inline Int_t WriteObject(const T* obj, const char* name, Option_t *option="") // see TDirectory::WriteObject or TDirectoryWriteObjectAny for explanation { return WriteObjectAny(obj,TBuffer::GetClass(typeid(T)),name,option); } - virtual Int_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option=""); - virtual Int_t WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option=""); - virtual void WriteDirHeader(); - virtual void WriteKeys(); + virtual Int_t WriteObjectAny(const void *, const char * /*classname*/, const char * /*name*/, Option_t * /*option*/="") {return 0;} + virtual Int_t WriteObjectAny(const void *, const TClass * /*cl*/, const char * /*name*/, Option_t * /*option*/="") {return 0;} + virtual void WriteDirHeader() {} + virtual void WriteKeys() {} static Bool_t Cd(const char *path); static void DecodeNameCycle(const char *namecycle, char *name, Short_t &cycle); static void EncodeNameCycle(char *buffer, const char *name, Short_t cycle); - ClassDef(TDirectory,4) //Describe directory structure in memory + ClassDef(TDirectory,5) //Describe directory structure in memory }; #endif diff --git a/base/inc/TFile.h b/base/inc/TFile.h index 063bcdcf7ee1873269d4697056d5cee26d2d019c..8a8a6b8820c067dd562f777ccc815314a1ba1524 100644 --- a/base/inc/TFile.h +++ b/base/inc/TFile.h @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TFile.h,v 1.56 2006/09/11 08:11:04 brun Exp $ +// @(#)root/base:$Name: $:$Id: TFile.h,v 1.57 2006/10/05 14:53:48 rdm Exp $ // Author: Rene Brun 28/11/94 /************************************************************************* @@ -21,8 +21,8 @@ // // ////////////////////////////////////////////////////////////////////////// -#ifndef ROOT_TDirectory -#include "TDirectory.h" +#ifndef ROOT_TDirectoryFile +#include "TDirectoryFile.h" #endif #ifndef ROOT_TUrl #include "TUrl.h" @@ -35,8 +35,8 @@ class TFileOpenHandle; class TFileCacheRead; class TFileCacheWrite; -class TFile : public TDirectory { - friend class TDirectory; +class TFile : public TDirectoryFile { + friend class TDirectoryFile; public: // Asynchronous open request status diff --git a/base/inc/TROOT.h b/base/inc/TROOT.h index 401022dd2c9f2d66564d7f6d96ce9e9ee7149fe7..6454a84bd6b425f4ff2d7f7835c6c6de16402638 100644 --- a/base/inc/TROOT.h +++ b/base/inc/TROOT.h @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.56 2006/12/01 11:50:14 rdm Exp $ +// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.57 2007/01/17 11:55:01 brun Exp $ // Author: Rene Brun 08/12/94 /************************************************************************* @@ -195,7 +195,7 @@ public: TSeqCollection *GetListOfDataSets() const { return fDataSets; } TList *GetListOfBrowsables() const { return fBrowsables; } TDataType *GetType(const char *name, Bool_t load = kFALSE) const; - TFile *GetFile() const { return fFile; } + TFile *GetFile() const { if (gDirectory != this) return gDirectory->GetFile(); else return 0;} TFile *GetFile(const char *name) const; TStyle *GetStyle(const char *name) const; TObject *GetFunction(const char *name) const; diff --git a/base/inc/TUUID.h b/base/inc/TUUID.h index e78b08897e01d5e0e2a6481562d18d1dff0a0d28..0a5b004ba3e1553bff413ac274e1ac9239efd153 100644 --- a/base/inc/TUUID.h +++ b/base/inc/TUUID.h @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TUUID.h,v 1.11 2004/04/15 22:33:53 rdm Exp $ +// @(#)root/base:$Name: $:$Id: TUUID.h,v 1.12 2004/07/22 06:28:09 brun Exp $ // Author: Fons Rademakers 30/9/2001 /************************************************************************* @@ -43,9 +43,6 @@ class TDatime; class TUUID { -friend class TFile; -friend class TDirectory; - protected: UInt_t fUUIDIndex; //!index in the list of UUIDs in TProcessUUID UInt_t fTimeLow; // 60 bit time, lower 32 bits @@ -68,11 +65,6 @@ protected: void GetRandomInfo(UChar_t seed[16]); void SetFromString(const char *uuid_str); - void StreamerV1(TBuffer &b); - void FillBuffer(char *&buffer); - void ReadBuffer(char *&buffer); - Int_t Sizeof() const { return 18; } - public: TUUID(); TUUID(const char *uuid_str); @@ -89,6 +81,11 @@ public: UInt_t GetUUIDNumber() const { return fUUIDIndex; } void SetUUIDNumber(UInt_t index) { fUUIDIndex = index; } + void StreamerV1(TBuffer &b); + void FillBuffer(char *&buffer); + void ReadBuffer(char *&buffer); + Int_t Sizeof() const { return 18; } + ClassDef(TUUID,1) // Universally Unique IDentifier }; diff --git a/base/src/TDirectory.cxx b/base/src/TDirectory.cxx index 0446bf7880b2f1ae9fb57ef29683f8f4b9dacc8b..f37d765b1006e6606d59dcd2318793a750b5903f 100644 --- a/base/src/TDirectory.cxx +++ b/base/src/TDirectory.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TDirectory.cxx,v 1.88 2006/07/14 19:49:59 pcanal Exp $ +// @(#)root/base:$Name: $:$Id: TDirectory.cxx,v 1.89 2006/09/14 07:02:00 brun Exp $ // Author: Rene Brun 28/11/94 /************************************************************************* @@ -12,25 +12,18 @@ #include "Riostream.h" #include "Strlen.h" #include "TDirectory.h" -#include "TFile.h" -#include "TMapFile.h" #include "TClassTable.h" #include "TInterpreter.h" #include "THashList.h" #include "TBrowser.h" -#include "TFree.h" -#include "TKey.h" #include "TROOT.h" #include "TError.h" -#include "Bytes.h" #include "TClass.h" #include "TRegexp.h" -#include "TProcessUUID.h" #include "TVirtualMutex.h" TDirectory *gDirectory; //Pointer to current directory in memory -const UInt_t kIsBigFile = BIT(16); const Int_t kMaxLen = 2048; //______________________________________________________________________________ @@ -44,33 +37,16 @@ ClassImp(TDirectory) //______________________________________________________________________________ // -// A ROOT file is structured in Directories (like a file system). -// Each Directory has a list of Keys (see TKeys) and a list of objects -// in memory. A Key is a small object that describes the type and location -// of a persistent object in a file. The persistent object may be a directory. -//Begin_Html -/* -<img src="gif/fildir.gif"> -*/ -//End_Html -// -// The structure of a file is shown in TFile::TFile -// //______________________________________________________________________________ TDirectory::TDirectory() : TNamed(), fMother(0) { //*-*-*-*-*-*-*-*-*-*-*-*Directory default constructor-*-*-*-*-*-*-*-*-*-*-*-* //*-* ============================= - fFile = 0; - fList = 0; - fKeys = 0; - fWritable = kFALSE; - fBufferSize = 0; } //______________________________________________________________________________ -TDirectory::TDirectory(const char *name, const char *title, Option_t *classname, TDirectory* initMotherDir) +TDirectory::TDirectory(const char *name, const char *title, Option_t * /*classname*/, TDirectory* initMotherDir) : TNamed(name, title), fMother(0) { //*-*-*-*-*-*-*-*-*-*-*-* Create a new Directory *-*-*-*-*-*-*-*-*-*-*-*-*-* @@ -100,46 +76,7 @@ TDirectory::TDirectory(const char *name, const char *title, Option_t *classname, Build(initMotherDir ? initMotherDir->GetFile() : 0, initMotherDir); - TDirectory* motherdir = GetMotherDir(); - TFile* f = GetFile(); - - if ((motherdir==0) || (f==0)) return; - if (!f->IsWritable()) return; //*-* in case of a directory in memory - if (motherdir->GetKey(name)) { - Error("TDirectory","An object with name %s exists already", name); - return; - } - TClass *cl = IsA(); - if (strlen(classname) != 0) cl = gROOT->GetClass(classname); - - if (!cl) { - Error("TDirectory","Invalid class name: %s",classname); - return; - } - fBufferSize = 0; - fWritable = kTRUE; - - if (f->IsBinary()) { - fSeekParent = f->GetSeekDir(); - Int_t nbytes = TDirectory::Sizeof(); - TKey *key = new TKey(fName,fTitle,cl,nbytes,motherdir); - fNbytesName = key->GetKeylen(); - fSeekDir = key->GetSeekKey(); - if (fSeekDir == 0) return; - char *buffer = key->GetBuffer(); - TDirectory::FillBuffer(buffer); - Int_t cycle = motherdir->AppendKey(key); - key->WriteFile(cycle); - } else { - fSeekParent = 0; - fNbytesName = 0; - fSeekDir = f->DirCreateEntry(this); - if (fSeekDir == 0) return; - } - - fModified = kFALSE; R__LOCKGUARD2(gROOTMutex); - gROOT->GetUUIDs()->AddUUID(fUUID,this); } //______________________________________________________________________________ @@ -163,18 +100,8 @@ TDirectory::~TDirectory() SafeDelete(fList); } - if (fKeys) { - fKeys->Delete("slow"); - SafeDelete(fKeys); - } - if (gDirectory == this) { - if (gFile != this) { - gFile->cd(); - } else { gDirectory = gROOT; - gFile = 0; - } } TDirectory* mom = GetMotherDir(); @@ -196,42 +123,6 @@ void TDirectory::Append(TObject *obj) if (obj == 0 || fList == 0) return; fList->Add(obj); obj->SetBit(kMustCleanup); - if (!fMother) return; - if (fMother->IsA() == TMapFile::Class()) { - TMapFile *mfile = (TMapFile*)fMother; - mfile->Add(obj); - } -} - -//______________________________________________________________________________ -Int_t TDirectory::AppendKey(TKey *key) -{ -//*-*-*-*-*-*-*Insert key in the linked list of keys of this directory*-*-*-* -//*-* ======================================================= - - fModified = kTRUE; - - key->SetMotherDir(this); - - // This is a fast hash lookup in case the key does not already exist - TKey *oldkey = (TKey*)fKeys->FindObject(key->GetName()); - if (!oldkey) { - fKeys->Add(key); - return 1; - } - - // If the key name already exists we have to make a scan for it - // and insert the new key ahead of the current one - TObjLink *lnk = fKeys->FirstLink(); - while (lnk) { - oldkey = (TKey*)lnk->GetObject(); - if (!strcmp(oldkey->GetName(), key->GetName())) - break; - lnk = lnk->Next(); - } - - fKeys->AddBefore(lnk, key); - return oldkey->GetCycle() + 1; } //______________________________________________________________________________ @@ -239,48 +130,21 @@ void TDirectory::Browse(TBrowser *b) { // Browse the content of the directory. - Char_t name[kMaxLen]; - if (b) { TObject *obj = 0; TIter nextin(fList); - TKey *key = 0, *keyo = 0; - TIter next(fKeys); cd(); //Add objects that are only in memory while ((obj = nextin())) { - if (fKeys->FindObject(obj->GetName())) continue; b->Add(obj, obj->GetName()); } - - //Add keys - while ((key = (TKey *) next())) { - int skip = 0; - if (!keyo || (keyo && strcmp(keyo->GetName(), key->GetName()))) { - skip = 0; - obj = fList->FindObject(key->GetName()); - - if (obj) { - sprintf(name, "%s", obj->GetName()); - b->Add(obj, name); - if (obj->IsFolder()) skip = 1; - } - } - - if (!skip) { - sprintf(name, "%s;%d", key->GetName(), key->GetCycle()); - b->Add(key, name); - } - - keyo = key; - } } } //______________________________________________________________________________ -void TDirectory::Build(TFile* motherFile, TDirectory* motherDir) +void TDirectory::Build(TFile* /*motherFile*/, TDirectory* motherDir) { //*-*-*-*-*-*-*-*-*-*-*-*Initialise directory to defaults*-*-*-*-*-*-*-*-*-* //*-* ================================ @@ -291,18 +155,8 @@ void TDirectory::Build(TFile* motherFile, TDirectory* motherDir) if (motherDir && strlen(GetName()) != 0) motherDir->Append(this); - fModified = kTRUE; - fWritable = kFALSE; - fDatimeC.Set(); - fDatimeM.Set(); - fNbytesKeys = 0; - fSeekDir = 0; - fSeekParent = 0; - fSeekKeys = 0; fList = new THashList(100,50); - fKeys = new THashList(100,50); fMother = motherDir; - fFile = motherFile ? motherFile : gFile; SetBit(kCanDelete); } @@ -352,8 +206,7 @@ TDirectory *TDirectory::GetDirectory(const char *apath, // path starts with a slash (assumes current file) if (path[0] == '/') { - TDirectory *td = fFile; - if (!fFile) td = gROOT; + TDirectory *td = gROOT; result = td->GetDirectory(path+1,printError,funcname); delete [] path; return result; } @@ -432,7 +285,6 @@ Bool_t TDirectory::cd1(const char *apath) if (apath) nch = strlen(apath); if (!nch) { gDirectory = this; - gFile = GetFile(); return kTRUE; } @@ -513,17 +365,12 @@ void TDirectory::Close(Option_t *) if (fast) fList->Delete(); else fList->Delete("slow"); - // Delete keys from key list (but don't delete the list header) - if (fKeys) { - fKeys->Delete("slow"); - } if (gDirectory == this) { TDirectory *cursav = GetMotherDir(); if (cursav && cursav != this) { cursav->cd(); } else { - gFile = 0; if (this == gROOT) { gDirectory = 0; } else { @@ -612,54 +459,6 @@ void TDirectory::Delete(const char *namecycle) idcur->Delete(name); } } -// if (deleteOK == 2) { -// Info("Delete","Dir:%x %s", fList->FindObject(name), name); -// delete fList->FindObject(name); //deleting a TDirectory -// } - } -//*-*---------------------Case of Key--------------------- -// =========== - if (cycle != 9999 ) { - if (IsWritable()) { - TKey *key; - TIter nextkey(GetListOfKeys()); - while ((key = (TKey *) nextkey())) { - deleteOK = 0; - s = key->GetName(); - if (deleteall || s.Index(re) != kNPOS) { - if (cycle == key->GetCycle()) deleteOK = 1; - if (cycle > 9999) deleteOK = 1; - if (!strcmp(key->GetClassName(),"TDirectory")) { - deleteOK = 2; - if (!deletetree && deleteall) deleteOK = 0; - if (cycle == key->GetCycle()) deleteOK = 2; - } - } - if (deleteOK) { - if (deleteOK==2) { - // read directory with subdirectories to correctly delete and free key structure - TDirectory* dir = GetDirectory(key->GetName(), kTRUE, "Delete"); - if (dir!=0) { - dir->Delete("T*;*"); - fList->Remove(dir); - delete dir; - } - } - - key->Delete(); - fKeys->Remove(key); - fModified = kTRUE; - delete key; - } - } - TFile* f = GetFile(); - if (fModified && (f!=0)) { - WriteKeys(); //*-* Write new keys structure - WriteDirHeader(); //*-* Write new directory header - f->WriteFree(); //*-* Write new free segments list - f->WriteHeader(); //*-* Write new file header - } - } } } @@ -674,81 +473,6 @@ void TDirectory::Draw(Option_t *option) fList->R__FOR_EACH(TObject,Draw)(option); } -//______________________________________________________________________________ -void TDirectory::FillBuffer(char *&buffer) -{ -//*-*-*-*-*-*-*-*-*-*-*-*Encode directory header into output buffer*-*-*-*-*-* -//*-* ========================================= - Version_t version = TDirectory::Class_Version(); - if (fSeekKeys > TFile::kStartBigFile) version += 1000; - tobuf(buffer, version); - fDatimeC.FillBuffer(buffer); - fDatimeM.FillBuffer(buffer); - tobuf(buffer, fNbytesKeys); - tobuf(buffer, fNbytesName); - if (version > 1000) { - tobuf(buffer, fSeekDir); - tobuf(buffer, fSeekParent); - tobuf(buffer, fSeekKeys); - } else { - tobuf(buffer, (Int_t)fSeekDir); - tobuf(buffer, (Int_t)fSeekParent); - tobuf(buffer, (Int_t)fSeekKeys); - } - fUUID.FillBuffer(buffer); - if (fFile && fFile->GetVersion() < 40000) return; - if (version <=1000) for (Int_t i=0;i<3;i++) tobuf(buffer,Int_t(0)); -} - -//______________________________________________________________________________ -TKey *TDirectory::FindKey(const char *keyname) const -{ - // Find key with name keyname in the current directory - - Short_t cycle; - char name[kMaxLen]; - - DecodeNameCycle(keyname, name, cycle); - return GetKey(name,cycle); -} - -//______________________________________________________________________________ -TKey *TDirectory::FindKeyAny(const char *keyname) const -{ - // Find key with name keyname in the current directory or - // its subdirectories. - // NOTE that If a key is found, the directory containing the key becomes - // the current directory - - TDirectory *dirsav = gDirectory; - Short_t cycle; - char name[kMaxLen]; - - DecodeNameCycle(keyname, name, cycle); - - TIter next(GetListOfKeys()); - TKey *key; - while ((key = (TKey *) next())) { - if (!strcmp(name, key->GetName())) - if ((cycle == 9999) || (cycle >= key->GetCycle())) { - ((TDirectory*)this)->cd(); // may be we should not make cd ??? - return key; - } - } - //try with subdirectories - next.Reset(); - while ((key = (TKey *) next())) { - if (!strcmp(key->GetClassName(),"TDirectory")) { - TDirectory* subdir = - ((TDirectory*)this)->GetDirectory(key->GetName(), kTRUE, "FindKeyAny"); - TKey *k = (subdir!=0) ? subdir->FindKeyAny(keyname) : 0; - if (k) return k; - } - } - if (dirsav) dirsav->cd(); - return 0; -} - //______________________________________________________________________________ TObject *TDirectory::FindObject(const TObject *obj) const { @@ -775,36 +499,7 @@ TObject *TDirectory::FindObjectAny(const char *aname) const // use FindKeyAny(aname)->ReadObj(). //object may be already in the list of objects in memory - TObject *obj = fList->FindObject(aname); - if (obj) return obj; - - TDirectory *dirsav = gDirectory; - Short_t cycle; - char name[kMaxLen]; - - DecodeNameCycle(aname, name, cycle); - - TIter next(GetListOfKeys()); - TKey *key; - //may be a key in the current directory - while ((key = (TKey *) next())) { - if (!strcmp(name, key->GetName())) { - if (cycle == 9999) return key->ReadObj(); - if (cycle >= key->GetCycle()) return key->ReadObj(); - } - } - //try with subdirectories - next.Reset(); - while ((key = (TKey *) next())) { - if (!strcmp(key->GetClassName(),"TDirectory")) { - TDirectory* subdir = - ((TDirectory*)this)->GetDirectory(key->GetName(), kTRUE, "FindKeyAny"); - TKey *k = subdir==0 ? 0 : subdir->FindKeyAny(aname); - if (k) { if (dirsav) dirsav->cd(); return k->ReadObj();} - } - } - if (dirsav) dirsav->cd(); - return 0; + return fList->FindObject(aname); } //______________________________________________________________________________ @@ -884,21 +579,6 @@ TObject *TDirectory::Get(const char *namecycle) idcur = 0; } } - -//*-*---------------------Case of Key--------------------- -// =========== - TKey *key; - TIter nextkey(GetListOfKeys()); - while ((key = (TKey *) nextkey())) { - if (strcmp(namobj,key->GetName()) == 0) { - if ((cycle == 9999) || (cycle == key->GetCycle())) { - TDirectory::TContext ctxt(this); - idcur = key->ReadObj(); - break; - } - } - } - return idcur; } @@ -993,50 +673,6 @@ void *TDirectory::GetObjectChecked(const char *namecycle, const TClass* expected } } -//*-*---------------------Case of Key--------------------- -// =========== - void *idcur = 0; - TKey *key; - TIter nextkey(GetListOfKeys()); - while ((key = (TKey *) nextkey())) { - if (strcmp(namobj,key->GetName()) == 0) { - if ((cycle == 9999) || (cycle == key->GetCycle())) { - TDirectory::TContext ctxt(this); - idcur = key->ReadObjectAny(expectedClass); - break; - } - } - } - - return idcur; -} - -//______________________________________________________________________________ -Int_t TDirectory::GetBufferSize() const -{ - // Return the buffer size to create new TKeys. - // If the stored fBufferSize is null, the value returned is the average - // buffer size of objects in the file so far. - - if (fBufferSize <= 0) return fFile->GetBestBuffer(); - else return fBufferSize; -} - - -//______________________________________________________________________________ -TKey *TDirectory::GetKey(const char *name, Short_t cycle) const -{ -//*-*-*-*-*-*-*-*-*-*-*Return pointer to key with name,cycle*-*-*-*-*-*-*-* -//*-* ===================================== -// if cycle = 9999 returns highest cycle -// - TKey *key; - TIter next(GetListOfKeys()); - while ((key = (TKey *) next())) - if (!strcmp(name, key->GetName())) { - if (cycle == 9999) return key; - if (cycle >= key->GetCycle()) return key; - } return 0; } @@ -1124,10 +760,6 @@ TDirectory *TDirectory::mkdir(const char *name, const char *title) ::Error("TDirectory::mkdir","directory name (%s) cannot contain a slash", name); return 0; } - if (GetKey(name)) { - Error("mkdir","An object with name %s exists already",name); - return 0; - } TDirectory::TContext ctxt(this); @@ -1142,12 +774,10 @@ void TDirectory::ls(Option_t *option) const //*-*-*-*-*-*-*-*-*-*-*-*List Directory contents*-*-*-*-*-*-*-*-*-*-*-*-*-* //*-* ======================= // Indentation is used to identify the directory tree -// Subdirectories are listed first, then objects in memory, then objects on the file +// Subdirectories are listed first, then objects in memory. // // The option can has the following format: -// [-d |-m][<regexp>] -// Option -d means: only list objects in the file -// -m means: only list objects in memory +// [<regexp>] // The <regexp> will be used to match the name of the objects. // By default memory and disk objects are listed. // @@ -1182,16 +812,6 @@ void TDirectory::ls(Option_t *option) const obj->ls(option); //*-* Loop on all the objects in memory } } - - if (diskobj) { - TKey *key; - TIter next(GetListOfKeys()); - while ((key = (TKey *) next())) { - TString s = key->GetName(); - if (s.Index(re) == kNPOS) continue; - key->ls(); //*-* Loop on all the keys - } - } TROOT::DecreaseDirLevel(); } @@ -1215,36 +835,6 @@ void TDirectory::Print(Option_t *option) const fList->R__FOR_EACH(TObject,Print)(option); } -//______________________________________________________________________________ -void TDirectory::Purge(Short_t) -{ - // Purge lowest key cycles in a directory. - // By default, only the highest cycle of a key is kept. Keys for which - // the "KEEP" flag has been set are not removed. See TKey::Keep(). - - if (!IsWritable()) return; - - TDirectory::TContext ctxt(this); - - TKey *key; - TIter prev(GetListOfKeys(), kIterBackward); - - while ((key = (TKey*)prev())) { // reverse loop on keys - TKey *keyprev = (TKey*)GetListOfKeys()->Before(key); - if (!keyprev) break; - if (key->GetKeep() == 0) { - if (strcmp(key->GetName(), keyprev->GetName()) == 0) key->Delete(); - } - } - TFile* f = GetFile(); - if (fModified && (f!=0)) { - WriteKeys(); // Write new keys structure - WriteDirHeader(); // Write new directory header - f->WriteFree(); // Write new free segments list - f->WriteHeader(); // Write new file header - } -} - //______________________________________________________________________________ void TDirectory::pwd() const { @@ -1253,131 +843,6 @@ void TDirectory::pwd() const Printf("%s", GetPath()); } -//______________________________________________________________________________ -void TDirectory::ReadAll(Option_t* opt) -{ - // Read objects from a ROOT db file directory into memory. - // If an object is already in memory, the memory copy is deleted - // and the object is again read from the file. - // If opt=="dirs", only subdirectories will be read - // If opt=="dirs*" complete directory tree will be read - - TDirectory::TContext ctxt(this); - - TKey *key; - TIter next(GetListOfKeys()); - - Bool_t readdirs = ((opt!=0) && ((strcmp(opt,"dirs")==0) || (strcmp(opt,"dirs*")==0))); - - if (readdirs) - while ((key = (TKey *) next())) { - - if (strcmp(key->GetClassName(),"TDirectory")!=0) continue; - - TDirectory *dir = GetDirectory(key->GetName(), kTRUE, "ReadAll"); - - if ((dir!=0) && (strcmp(opt,"dirs*")==0)) dir->ReadAll("dirs*"); - } - else - while ((key = (TKey *) next())) { - TObject *thing = GetList()->FindObject(key->GetName()); - if (thing) { delete thing; } - thing = key->ReadObj(); - } -} - -//______________________________________________________________________________ -Int_t TDirectory::ReadKeys() -{ -//*-*-*-*-*-*-*-*-*-*-*-*-*Read the KEYS linked list*-*-*-*-*-*-*-*-*-*-*-*-* -//*-* ========================= -// Every directory has a linked list (fKeys). This linked list has been -// written on the file via WriteKeys as a single data record. -// -// It is interesting to call this function in the following situation. -// Assume another process1 is connecting this directory in Update mode -// -Process1 is adding/updating objects in this directory -// -You want to see the latest status from process1. -// Example Process1: -// obj1.Write(); -// obj2.Write(); -// gDirectory->SaveSelf(); -// -// Example Process2 -// gDirectory->ReadKeys(); -// obj1->Draw(); -// -// This is an efficient way (without opening/closing files) to view -// the latest updates of a file being modified by another process -// as it is typically the case in a data acquisition system. - - if (fFile==0) return 0; - - if (!fFile->IsBinary()) - return fFile->DirReadKeys(this); - - TDirectory::TContext ctxt(this); - - fKeys->Delete(); - //In case directory was updated by another process, read new - //position for the keys - Int_t nbytes = fNbytesName + TDirectory::Sizeof(); - char *header = new char[nbytes]; - char *buffer = header; - fFile->Seek(fSeekDir); - fFile->ReadBuffer(buffer,nbytes); - buffer += fNbytesName; - Version_t versiondir; - frombuf(buffer,&versiondir); - fDatimeC.ReadBuffer(buffer); - fDatimeM.ReadBuffer(buffer); - frombuf(buffer, &fNbytesKeys); - frombuf(buffer, &fNbytesName); - if (versiondir > 1000) { - frombuf(buffer, &fSeekDir); - frombuf(buffer, &fSeekParent); - frombuf(buffer, &fSeekKeys); - } else { - Int_t sdir,sparent,skeys; - frombuf(buffer, &sdir); fSeekDir = (Long64_t)sdir; - frombuf(buffer, &sparent); fSeekParent = (Long64_t)sparent; - frombuf(buffer, &skeys); fSeekKeys = (Long64_t)skeys; - } - delete [] header; - - Int_t nkeys = 0; - Long64_t fsize = fFile->GetSize(); - if ( fSeekKeys > 0) { - TKey *headerkey = new TKey(fSeekKeys, fNbytesKeys, this); - headerkey->ReadFile(); - buffer = headerkey->GetBuffer(); - headerkey->ReadKeyBuffer(buffer); - - TKey *key; - frombuf(buffer, &nkeys); - for (Int_t i = 0; i < nkeys; i++) { - key = new TKey(this); - key->ReadKeyBuffer(buffer); - if (key->GetSeekKey() < 64 || key->GetSeekKey() > fsize) { - Error("ReadKeys","reading illegal key, exiting after %d keys",i); - fKeys->Remove(key); - nkeys = i; - break; - } - if (key->GetSeekPdir() < 64 || key->GetSeekPdir() > fsize) { - Error("ReadKeys","reading illegal key, exiting after %d keys",i); - fKeys->Remove(key); - nkeys = i; - break; - } - fKeys->Add(key); - } - delete headerkey; - } - - return nkeys; -} - //______________________________________________________________________________ void TDirectory::RecursiveRemove(TObject *obj) { @@ -1402,69 +867,6 @@ void TDirectory::rmdir(const char *name) Delete(mask); } -//______________________________________________________________________________ -void TDirectory::Save() -{ -//*-*-*-*-*-*-*-*-*-*Save recursively all directory keys and headers-*-*-*-*-* -//*-* =============================================== - - TDirectory::TContext ctxt(this); - - SaveSelf(); - - // recursively save all sub-directories - if (fList) { - TObject *idcur; - TIter next(fList); - while ((idcur = next())) { - if (idcur->InheritsFrom(TDirectory::Class())) { - TDirectory *dir = (TDirectory*)idcur; - dir->Save(); - } - } - } -} - -//______________________________________________________________________________ -void TDirectory::SaveSelf(Bool_t force) -{ -//*-*-*-*-*-*-*-*-*-*Save Directory keys and header*-*-*-*-*-*-*-*-*-*-*-* -//*-* ============================== -// If the directory has been modified (fModified set), write the keys -// and the directory header. This function assumes the cd is correctly set. -// -// It is recommended to use this function in the following situation: -// Assume a process1 using a directory in Update mode -// -New objects or modified objects have been written to the directory -// -You do not want to close the file -// -You want your changes be visible from another process2 already connected -// to this directory in read mode -// -Call this function -// -In process2, use TDirectory::ReadKeys to refresh the directory - - if (IsWritable() && (fModified || force) && fFile) { - Bool_t dowrite = kTRUE; - if (fFile->GetListOfFree()) - dowrite = fFile->GetListOfFree()->First() != 0; - if (dowrite) { - TDirectory *dirsav = gDirectory; - if (dirsav != this) cd(); - WriteKeys(); //*-*- Write keys record - WriteDirHeader(); //*-*- Update directory record - if (dirsav && dirsav != this) dirsav->cd(); - } - } -} - -//______________________________________________________________________________ -void TDirectory::SetBufferSize(Int_t bufsize) -{ - // set the default buffer size when creating new TKeys - // see also TDirectory::GetBufferSize - - fBufferSize = bufsize; -} - //______________________________________________________________________________ void TDirectory::SetName(const char* newname) { @@ -1478,496 +880,6 @@ void TDirectory::SetName(const char* newname) TNamed::SetName(newname); } -//______________________________________________________________________________ -void TDirectory::SetWritable(Bool_t writable) -{ -// Set the new value of fWritable recursively - - TDirectory::TContext ctxt(this); - - fWritable = writable; - - // recursively set all sub-directories - if (fList) { - TObject *idcur; - TIter next(fList); - while ((idcur = next())) { - if (idcur->InheritsFrom(TDirectory::Class())) { - TDirectory *dir = (TDirectory*)idcur; - dir->SetWritable(writable); - } - } - } -} - - -//______________________________________________________________________________ -Int_t TDirectory::Sizeof() const -{ -//*-*-*-*-*-*-*Return the size in bytes of the directory header*-*-*-*-*-*-* -//*-* ================================================ - //Int_t nbytes = sizeof(Version_t); 2 - //nbytes += fDatimeC.Sizeof(); - //nbytes += fDatimeM.Sizeof(); - //nbytes += sizeof fNbytesKeys; 4 - //nbytes += sizeof fNbytesName; 4 - //nbytes += sizeof fSeekDir; 4 or 8 - //nbytes += sizeof fSeekParent; 4 or 8 - //nbytes += sizeof fSeekKeys; 4 or 8 - //nbytes += fUUID.Sizeof(); - Int_t nbytes = 22; - nbytes += fDatimeC.Sizeof(); - nbytes += fDatimeM.Sizeof(); - nbytes += fUUID.Sizeof(); - //assume that the file may be above 2 Gbytes if file version is > 4 - if (fFile && fFile->GetVersion() >= 40000) nbytes += 12; - return nbytes; -} - - -//_______________________________________________________________________ -void TDirectory::Streamer(TBuffer &b) -{ -//*-*-*-*-*-*-*-*-*Stream a class object*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -//*-* ========================================= - - Version_t v,version; - if (b.IsReading()) { - Build((TFile*)b.GetParent(), 0); - if (fFile && fFile->IsWritable()) fWritable = kTRUE; - - if (fFile && !fFile->IsBinary()) { - Version_t R__v = b.ReadVersion(0, 0); - b.ClassBegin(TDirectory::Class(), R__v); - - TString sbuf; - - b.ClassMember("CreateTime","TString"); - sbuf.Streamer(b); - TDatime timeC(sbuf.Data()); - fDatimeC = timeC; - - b.ClassMember("ModifyTime","TString"); - sbuf.Streamer(b); - TDatime timeM(sbuf.Data()); - fDatimeM = timeM; - - b.ClassMember("UUID","TString"); - sbuf.Streamer(b); - TUUID id(sbuf.Data()); - fUUID = id; - - b.ClassEnd(TDirectory::Class()); - - fSeekKeys = 0; // read keys later in the TKeySQL class - } else { - b >> version; - fDatimeC.Streamer(b); - fDatimeM.Streamer(b); - b >> fNbytesKeys; - b >> fNbytesName; - if (version > 1000) { - SetBit(kIsBigFile); - b >> fSeekDir; - b >> fSeekParent; - b >> fSeekKeys; - } else { - Int_t sdir,sparent,skeys; - b >> sdir; fSeekDir = (Long64_t)sdir; - b >> sparent; fSeekParent = (Long64_t)sparent; - b >> skeys; fSeekKeys = (Long64_t)skeys; - } - v = version%1000; - if (v == 2) { - fUUID.StreamerV1(b); - } else if (v > 2) { - fUUID.Streamer(b); - } - } - R__LOCKGUARD2(gROOTMutex); - gROOT->GetUUIDs()->AddUUID(fUUID,this); - if (fSeekKeys) ReadKeys(); - } else { - if (fFile && !fFile->IsBinary()) { - b.WriteVersion(TDirectory::Class()); - - TString sbuf; - - b.ClassBegin(TDirectory::Class()); - - b.ClassMember("CreateTime","TString"); - sbuf = fDatimeC.AsSQLString(); - sbuf.Streamer(b); - - b.ClassMember("ModifyTime","TString"); - fDatimeM.Set(); - sbuf = fDatimeM.AsSQLString(); - sbuf.Streamer(b); - - b.ClassMember("UUID","TString"); - sbuf = fUUID.AsString(); - sbuf.Streamer(b); - - b.ClassEnd(TDirectory::Class()); - } else { - version = TDirectory::Class_Version(); - if (fFile && fFile->GetEND() > TFile::kStartBigFile) version += 1000; - b << version; - fDatimeC.Streamer(b); - fDatimeM.Streamer(b); - b << fNbytesKeys; - b << fNbytesName; - if (version > 1000) { - b << fSeekDir; - b << fSeekParent; - b << fSeekKeys; - } else { - b << (Int_t)fSeekDir; - b << (Int_t)fSeekParent; - b << (Int_t)fSeekKeys; - } - fUUID.Streamer(b); - if (version <=1000) for (Int_t i=0;i<3;i++) b << Int_t(0); - } - } -} - -//______________________________________________________________________________ -Int_t TDirectory::Write(const char *, Int_t opt, Int_t bufsiz) -{ - // Write all objects in memory to disk. - // Loop on all objects in memory (including subdirectories). - // A new key is created in the KEYS linked list for each object. - // For allowed options see TObject::Write(). - // The directory header info is rewritten on the directory header record. - - if (!IsWritable()) return 0; - TDirectory::TContext ctxt(this); - - // Loop on all objects (including subdirs) - TIter next(fList); - TObject *obj; - Int_t nbytes = 0; - while ((obj=next())) { - nbytes += obj->Write(0,opt,bufsiz); - } - SaveSelf(kTRUE); // force save itself - - return nbytes; -} - -//______________________________________________________________________________ -Int_t TDirectory::Write(const char *n, Int_t opt, Int_t bufsize) const -{ - // One can not save a const TDirectory object. - - Error("Write const","A const TDirectory object should not be saved. We try to proceed anyway."); - return const_cast<TDirectory*>(this)->Write(n, opt, bufsize); -} - -//____________________________________________________________________________________ -Int_t TDirectory::WriteTObject(const TObject *obj, const char *name, Option_t *option) -{ - // Write object obj to this directory - // The data structure corresponding to this object is serialized. - // The corresponding buffer is written to this directory - // with an associated key with name "name". - // - // Writing an object to a file involves the following steps: - // - // -Creation of a support TKey object in the directory. - // The TKey object creates a TBuffer object. - // - // -The TBuffer object is filled via the class::Streamer function. - // - // -If the file is compressed (default) a second buffer is created to - // hold the compressed buffer. - // - // -Reservation of the corresponding space in the file by looking - // in the TFree list of free blocks of the file. - // - // -The buffer is written to the file. - // - // By default, the buffersize will be taken from the average buffer size - // of all objects written to the current file so far. - // Use TDirectory::SetBufferSize to force a given buffer size. - // - // If a name is specified, it will be the name of the key. - // If name is not given, the name of the key will be the name as returned - // by obj->GetName(). - // - // The option can be a combination of: - // "SingleKey", "Overwrite" or "WriteDelete" - // Using the "Overwrite" option a previous key with the same name is - // overwritten. The previous key is deleted before writing the new object. - // Using the "WriteDelete" option a previous key with the same name is - // deleted only after the new object has been written. This option - // is safer than kOverwrite but it is slower. - // The "SingleKey" option is only used by TCollection::Write() to write - // a container with a single key instead of each object in the container - // with its own key. - // - // An object is read from this directory via TDirectory::Get. - // - // The function returns the total number of bytes written to the directory. - // It returns 0 if the object cannot be written. - - TDirectory::TContext ctxt(this); - - if (fFile==0) return 0; - - if (!fFile->IsWritable()) { - if (!fFile->TestBit(TFile::kWriteError)) { - // Do not print the error if the file already had a SysError. - Error("WriteTObject","Directory %s is not writable", fFile->GetName()); - } - return 0; - } - - if (!obj) return 0; - - TString opt = option; - opt.ToLower(); - - TKey *key=0, *oldkey=0; - Int_t bsize = GetBufferSize(); - - const char *oname; - if (name && *name) - oname = name; - else - oname = obj->GetName(); - - // Remove trailing blanks in object name - Int_t nch = strlen(oname); - char *newName = 0; - if (oname[nch-1] == ' ') { - newName = new char[nch+1]; - strcpy(newName,oname); - for (Int_t i=0;i<nch;i++) { - if (newName[nch-i-1] != ' ') break; - newName[nch-i-1] = 0; - } - oname = newName; - } - - if (opt.Contains("overwrite")) { - //One must use GetKey. FindObject would return the lowest cycle of the key! - //key = (TKey*)gDirectory->GetListOfKeys()->FindObject(oname); - key = GetKey(oname); - if (key) { - key->Delete(); - delete key; - } - } - if (opt.Contains("writedelete")) { - oldkey = GetKey(oname); - } - key = fFile->CreateKey(this, obj, oname, bsize); - if (newName) delete [] newName; - - if (!key->GetSeekKey()) { - fKeys->Remove(key); - delete key; - return 0; - } - fFile->SumBuffer(key->GetObjlen()); - Int_t nbytes = key->WriteFile(0); - if (fFile->TestBit(TFile::kWriteError)) return 0; - - if (oldkey) { - oldkey->Delete(); - delete oldkey; - } - - return nbytes; -} - -//______________________________________________________________________________ -Int_t TDirectory::WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option) -{ - // Write object from pointer of class classname in this directory - // obj may not derive from TObject - // see TDirectory::WriteObject for comments - // - // VERY IMPORTANT NOTE: - // The value passed as 'obj' needs to be from a pointer to the type described by classname - // For example with: - // TopClass *top; - // BottomClass *bottom; - // top = bottom; - // you can do: - // directory->WriteObjectAny(top,"top","name of object"); - // directory->WriteObjectAny(bottom,"bottom","name of object"); - // BUT YOU CAN NOT DO (it will fail in particular with multiple inheritance): - // directory->WriteObjectAny(top,"bottom","name of object"); - // - // We STRONGLY recommend to use - // TopClass *top = ....; - // directory->WriteObject(top,"name of object") - - TClass *cl = ROOT::GetROOT()->GetClass(classname); - if (!cl) { - Error("WriteObjectAny","Unknown class: %s",classname); - return 0; - } - return WriteObjectAny(obj,cl,name,option); -} - -//______________________________________________________________________________ -Int_t TDirectory::WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option) -{ - // Write object of class with dictionary cl in this directory - // obj may not derive from TObject - // To get the TClass* cl pointer, one can use - // TClass *cl = gROOT->GetClass("classname"); - // An alternative is to call the function WriteObjectAny above. - // see TDirectory::WriteObject for comments - - TDirectory::TContext ctxt(this); - - if (fFile==0) return 0; - - if (!fFile->IsWritable()) { - if (!fFile->TestBit(TFile::kWriteError)) { - // Do not print the error if the file already had a SysError. - Error("WriteObject","File %s is not writable", fFile->GetName()); - } - return 0; - } - - if (!obj || !cl) return 0; - TKey *key, *oldkey=0; - Int_t bsize = GetBufferSize(); - - TString opt = option; - opt.ToLower(); - - const char *oname; - if (name && *name) - oname = name; - else - oname = cl->GetName(); - - // Remove trailing blanks in object name - Int_t nch = strlen(oname); - char *newName = 0; - if (oname[nch-1] == ' ') { - newName = new char[nch+1]; - strcpy(newName,oname); - for (Int_t i=0;i<nch;i++) { - if (newName[nch-i-1] != ' ') break; - newName[nch-i-1] = 0; - } - oname = newName; - } - - if (opt.Contains("overwrite")) { - //One must use GetKey. FindObject would return the lowest cycle of the key! - //key = (TKey*)gDirectory->GetListOfKeys()->FindObject(oname); - key = GetKey(oname); - if (key) { - key->Delete(); - delete key; - } - } - if (opt.Contains("writedelete")) { - oldkey = GetKey(oname); - } - key = fFile->CreateKey(this, obj, cl, oname, bsize); - if (newName) delete [] newName; - - if (!key->GetSeekKey()) { - fKeys->Remove(key); - delete key; - return 0; - } - fFile->SumBuffer(key->GetObjlen()); - Int_t nbytes = key->WriteFile(0); - if (fFile->TestBit(TFile::kWriteError)) return 0; - - if (oldkey) { - oldkey->Delete(); - delete oldkey; - } - - return nbytes; -} - -//______________________________________________________________________________ -void TDirectory::WriteDirHeader() -{ -//*-*-*-*-*-*-*-*-*-*-*Overwrite the Directory header record*-*-*-*-*-*-*-*-* -//*-* ===================================== - TFile* f = GetFile(); - if (f==0) return; - - if (!f->IsBinary()) { - fDatimeM.Set(); - f->DirWriteHeader(this); - return; - } - - Int_t nbytes = TDirectory::Sizeof(); //Warning ! TFile has a Sizeof() - char * header = new char[nbytes]; - char * buffer = header; - fDatimeM.Set(); - TDirectory::FillBuffer(buffer); - Long64_t pointer = fSeekDir + fNbytesName; // do not overwrite the name/title part - fModified = kFALSE; - f->Seek(pointer); - f->WriteBuffer(header, nbytes); - if (f->MustFlush()) f->Flush(); - delete [] header; -} - -//______________________________________________________________________________ -void TDirectory::WriteKeys() -{ -//*-*-*-*-*-*-*-*-*-*-*-*Write KEYS linked list on the file *-*-*-*-*-*-*-* -//*-* ================================== -// The linked list of keys (fKeys) is written as a single data record -// - - TFile* f = GetFile(); - if (f==0) return; - - if (!f->IsBinary()) { - f->DirWriteKeys(this); - return; - } - -//*-* Delete the old keys structure if it exists - if (fSeekKeys != 0) { - f->MakeFree(fSeekKeys, fSeekKeys + fNbytesKeys -1); - } -//*-* Write new keys record - TIter next(fKeys); - TKey *key; - Int_t nkeys = fKeys->GetSize(); - Int_t nbytes = sizeof nkeys; //*-* Compute size of all keys - if (f->GetEND() > TFile::kStartBigFile) nbytes += 8; - while ((key = (TKey*)next())) { - nbytes += key->Sizeof(); - } - TKey *headerkey = new TKey(fName,fTitle,IsA(),nbytes,this); - if (headerkey->GetSeekKey() == 0) { - delete headerkey; - return; - } - char *buffer = headerkey->GetBuffer(); - next.Reset(); - tobuf(buffer, nkeys); - while ((key = (TKey*)next())) { - key->FillBuffer(buffer); - } - - fSeekKeys = headerkey->GetSeekKey(); - fNbytesKeys = headerkey->GetNbytes(); - headerkey->WriteFile(); - delete headerkey; -} - //______________________________________________________________________________ void TDirectory::EncodeNameCycle(char *buffer, const char *name, Short_t cycle) { diff --git a/base/src/TFile.cxx b/base/src/TFile.cxx index 3119e84d35a4b5903d149cbf99255f56e80f4736..5d36d3ad4495d2239aca32b18bd6a6b448301894 100644 --- a/base/src/TFile.cxx +++ b/base/src/TFile.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TFile.cxx,v 1.197 2007/01/15 11:52:01 rdm Exp $ +// @(#)root/base:$Name: $:$Id: TFile.cxx,v 1.198 2007/01/15 22:08:28 rdm Exp $ // Author: Rene Brun 28/11/94 /************************************************************************* @@ -70,7 +70,7 @@ ClassImp(TFile) //*-*x17 macros/layout_file //______________________________________________________________________________ -TFile::TFile() : TDirectory(), fInfoCache(0) +TFile::TFile() : TDirectoryFile(), fInfoCache(0) { // File default Constructor. @@ -103,7 +103,7 @@ TFile::TFile() : TDirectory(), fInfoCache(0) //_____________________________________________________________________________ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t compress) - : TDirectory(), fUrl(fname1,kTRUE), fInfoCache(0) + : TDirectoryFile(), fUrl(fname1,kTRUE), fInfoCache(0) { // Opens or creates a local ROOT file whose name is fname1. It is // recommended to specify fname1 as "<file>.root". The suffix ".root" @@ -228,7 +228,7 @@ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t com */ //End_Html // - // The structure of a directory is shown in TDirectory::TDirectory + // The structure of a directory is shown in TDirectoryFile::TDirectoryFile if (!gROOT) ::Fatal("TFile::TFile", "ROOT system not initialized"); @@ -261,7 +261,7 @@ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t com fAsyncHandle = 0; fAsyncOpenStatus = kAOSNotAsync; - TDirectory::Build(this, 0); + TDirectoryFile::Build(this, 0); fD = -1; fFree = 0; @@ -417,7 +417,7 @@ zombie: } //______________________________________________________________________________ -TFile::TFile(const TFile &file) : TDirectory(), fInfoCache(0) +TFile::TFile(const TFile &file) : TDirectoryFile(), fInfoCache(0) { // Copy constructor. @@ -509,7 +509,7 @@ void TFile::Init(Bool_t create) //*-* Write Directory info Int_t namelen= TNamed::Sizeof(); - Int_t nbytes = namelen + TDirectory::Sizeof(); + Int_t nbytes = namelen + TDirectoryFile::Sizeof(); TKey *key = new TKey(fName, fTitle, IsA(), nbytes, this); fNbytesName = key->GetKeylen() + namelen; fSeekDir = key->GetSeekKey(); @@ -518,7 +518,7 @@ void TFile::Init(Bool_t create) WriteHeader(); char *buffer = key->GetBuffer(); TNamed::FillBuffer(buffer); - TDirectory::FillBuffer(buffer); + TDirectoryFile::FillBuffer(buffer); key->WriteFile(); delete key; } else { @@ -573,7 +573,7 @@ void TFile::Init(Bool_t create) } } //*-*-------------Read directory info - Int_t nbytes = fNbytesName + TDirectory::Sizeof(); + Int_t nbytes = fNbytesName + TDirectoryFile::Sizeof(); header = new char[nbytes]; buffer = header; Seek(fBEGIN); @@ -621,7 +621,7 @@ void TFile::Init(Bool_t create) //*-* -------------Read keys of the top directory if (fSeekKeys > fBEGIN && fEND <= size) { //normal case. Recover only if file has no keys - TDirectory::ReadKeys(); + TDirectoryFile::ReadKeys(); gDirectory = this; if (!GetNkeys()) Recover(); } else if ((fBEGIN+nbytes == fEND) && (fEND == size)) { @@ -714,8 +714,8 @@ void TFile::Close(Option_t *option) // Delete all supported directories structures from memory // If gDirectory points to this object or any of the nested - // TDirectory, TDirectory::Close will induce the proper cd. - TDirectory::Close(); + // TDirectoryFile, TDirectoryFile::Close will induce the proper cd. + TDirectoryFile::Close(); if (IsWritable()) { TFree *f1 = (TFree*)fFree->First(); @@ -796,7 +796,7 @@ void TFile::Delete(const char *namecycle) if (gDebug) Info("Delete", "deleting name = %s", namecycle); - TDirectory::Delete(namecycle); + TDirectoryFile::Delete(namecycle); } //______________________________________________________________________________ @@ -1071,7 +1071,7 @@ void TFile::ls(Option_t *option) const TROOT::IndentLevel(); cout <<ClassName()<<"**\t\t"<<GetName()<<"\t"<<GetTitle()<<endl; TROOT::IncreaseDirLevel(); - TDirectory::ls(option); + TDirectoryFile::ls(option); TROOT::DecreaseDirLevel(); } @@ -1715,7 +1715,7 @@ Int_t TFile::Write(const char *, Int_t opt, Int_t bufsiz) } fMustFlush = kFALSE; - Int_t nbytes = TDirectory::Write(0, opt, bufsiz); // Write directory tree + Int_t nbytes = TDirectoryFile::Write(0, opt, bufsiz); // Write directory tree WriteStreamerInfo(); WriteFree(); // Write free segments linked list WriteHeader(); // Now write file header diff --git a/base/src/TKey.cxx b/base/src/TKey.cxx index 609b9ee78e5ce3da7e0cc747ba8b688b29a935e2..cf90ee08e28a2bf57b6c52417fdf8d93a4aef402 100644 --- a/base/src/TKey.cxx +++ b/base/src/TKey.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.62 2007/01/12 16:03:15 brun Exp $ +// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.63 2007/01/19 16:47:59 brun Exp $ // Author: Rene Brun 28/12/94 /************************************************************************* @@ -40,7 +40,7 @@ // - to write a new ntuple buffer // // // // The structure of a file is shown in TFile::TFile. // -// The structure of a directory is shown in TDirectory::TDirectory. // +// The structure of a directory is shown in TDirectoryFile ctor. // // The TKey class is used by the TBasket class. // // See also TTree. // // // @@ -49,7 +49,7 @@ #include "Riostream.h" #include "TROOT.h" #include "TClass.h" -#include "TDirectory.h" +#include "TDirectoryFile.h" #include "TFile.h" #include "TKey.h" #include "TBufferFile.h" @@ -142,7 +142,7 @@ TKey::TKey(TDirectory* motherDir) : TNamed(), fDatime((UInt_t)0) TKey::TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir) : TNamed() { // Create a TKey object to read keys. - // Constructor called by TDirectory::ReadKeys and by TFile::TFile. + // Constructor called by TDirectoryFile::ReadKeys and by TFile::TFile. // A TKey object is created to read the keys structure itself. Build(motherDir, "", pointer); @@ -367,7 +367,7 @@ void TKey::Browse(TBrowser *b) { // Read object from disk and call its Browse() method. // If object with same name already exist in memory delete it (like - // TDirectory::Get() is doing), except when the key references a + // TDirectoryFile::Get() is doing), except when the key references a // folder in which case we don't want to re-read the folder object // since it might contain new objects not yet saved. @@ -737,8 +737,8 @@ TObject *TKey::ReadObj() if (gROOT->GetForceStyle()) tobj->UseCurrentStyle(); - if (cl == TDirectory::Class()) { - TDirectory *dir = dynamic_cast<TDirectory*>(tobj); + if (cl == TDirectoryFile::Class()) { + TDirectory *dir = dynamic_cast<TDirectoryFile*>(tobj); dir->SetName(GetName()); dir->SetTitle(GetTitle()); dir->SetMother(fMotherDir); @@ -873,8 +873,8 @@ void *TKey::ReadObjectAny(const TClass* expectedClass) // See similar adjustments in ReadObj if (gROOT->GetForceStyle()) tobj->UseCurrentStyle(); - if (cl == TDirectory::Class()) { - TDirectory *dir = dynamic_cast<TDirectory*>(tobj); + if (cl == TDirectoryFile::Class()) { + TDirectory *dir = dynamic_cast<TDirectoryFile*>(tobj); dir->SetName(GetName()); dir->SetTitle(GetTitle()); gDirectory->Append(dir); diff --git a/base/src/TMapFile.cxx b/base/src/TMapFile.cxx index 484de1ee08fb97bb071202eea3d304fa95fd73d9..bc5bcaf3279bf0d09f2719b00b183857d4323b54 100644 --- a/base/src/TMapFile.cxx +++ b/base/src/TMapFile.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TMapFile.cxx,v 1.23 2007/01/15 12:51:25 brun Exp $ +// @(#)root/base:$Name: $:$Id: TMapFile.cxx,v 1.24 2007/01/19 16:47:59 brun Exp $ // Author: Fons Rademakers 08/07/97 /************************************************************************* @@ -89,7 +89,7 @@ #include "TMapFile.h" #include "TKeyMapFile.h" -#include "TDirectory.h" +#include "TDirectoryFile.h" #include "TBrowser.h" #include "TString.h" #include "TSystem.h" @@ -519,7 +519,7 @@ void TMapFile::InitDirectory() // Create the directory associated to this mapfile gDirectory = 0; - fDirectory = new TDirectory(); + fDirectory = new TDirectoryFile(); fDirectory->SetName(GetName()); fDirectory->SetTitle(GetTitle()); fDirectory->Build(); diff --git a/io/inc/TFile.h b/io/inc/TFile.h index 063bcdcf7ee1873269d4697056d5cee26d2d019c..8a8a6b8820c067dd562f777ccc815314a1ba1524 100644 --- a/io/inc/TFile.h +++ b/io/inc/TFile.h @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TFile.h,v 1.56 2006/09/11 08:11:04 brun Exp $ +// @(#)root/base:$Name: $:$Id: TFile.h,v 1.57 2006/10/05 14:53:48 rdm Exp $ // Author: Rene Brun 28/11/94 /************************************************************************* @@ -21,8 +21,8 @@ // // ////////////////////////////////////////////////////////////////////////// -#ifndef ROOT_TDirectory -#include "TDirectory.h" +#ifndef ROOT_TDirectoryFile +#include "TDirectoryFile.h" #endif #ifndef ROOT_TUrl #include "TUrl.h" @@ -35,8 +35,8 @@ class TFileOpenHandle; class TFileCacheRead; class TFileCacheWrite; -class TFile : public TDirectory { - friend class TDirectory; +class TFile : public TDirectoryFile { + friend class TDirectoryFile; public: // Asynchronous open request status diff --git a/io/src/TFile.cxx b/io/src/TFile.cxx index 3119e84d35a4b5903d149cbf99255f56e80f4736..5d36d3ad4495d2239aca32b18bd6a6b448301894 100644 --- a/io/src/TFile.cxx +++ b/io/src/TFile.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TFile.cxx,v 1.197 2007/01/15 11:52:01 rdm Exp $ +// @(#)root/base:$Name: $:$Id: TFile.cxx,v 1.198 2007/01/15 22:08:28 rdm Exp $ // Author: Rene Brun 28/11/94 /************************************************************************* @@ -70,7 +70,7 @@ ClassImp(TFile) //*-*x17 macros/layout_file //______________________________________________________________________________ -TFile::TFile() : TDirectory(), fInfoCache(0) +TFile::TFile() : TDirectoryFile(), fInfoCache(0) { // File default Constructor. @@ -103,7 +103,7 @@ TFile::TFile() : TDirectory(), fInfoCache(0) //_____________________________________________________________________________ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t compress) - : TDirectory(), fUrl(fname1,kTRUE), fInfoCache(0) + : TDirectoryFile(), fUrl(fname1,kTRUE), fInfoCache(0) { // Opens or creates a local ROOT file whose name is fname1. It is // recommended to specify fname1 as "<file>.root". The suffix ".root" @@ -228,7 +228,7 @@ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t com */ //End_Html // - // The structure of a directory is shown in TDirectory::TDirectory + // The structure of a directory is shown in TDirectoryFile::TDirectoryFile if (!gROOT) ::Fatal("TFile::TFile", "ROOT system not initialized"); @@ -261,7 +261,7 @@ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t com fAsyncHandle = 0; fAsyncOpenStatus = kAOSNotAsync; - TDirectory::Build(this, 0); + TDirectoryFile::Build(this, 0); fD = -1; fFree = 0; @@ -417,7 +417,7 @@ zombie: } //______________________________________________________________________________ -TFile::TFile(const TFile &file) : TDirectory(), fInfoCache(0) +TFile::TFile(const TFile &file) : TDirectoryFile(), fInfoCache(0) { // Copy constructor. @@ -509,7 +509,7 @@ void TFile::Init(Bool_t create) //*-* Write Directory info Int_t namelen= TNamed::Sizeof(); - Int_t nbytes = namelen + TDirectory::Sizeof(); + Int_t nbytes = namelen + TDirectoryFile::Sizeof(); TKey *key = new TKey(fName, fTitle, IsA(), nbytes, this); fNbytesName = key->GetKeylen() + namelen; fSeekDir = key->GetSeekKey(); @@ -518,7 +518,7 @@ void TFile::Init(Bool_t create) WriteHeader(); char *buffer = key->GetBuffer(); TNamed::FillBuffer(buffer); - TDirectory::FillBuffer(buffer); + TDirectoryFile::FillBuffer(buffer); key->WriteFile(); delete key; } else { @@ -573,7 +573,7 @@ void TFile::Init(Bool_t create) } } //*-*-------------Read directory info - Int_t nbytes = fNbytesName + TDirectory::Sizeof(); + Int_t nbytes = fNbytesName + TDirectoryFile::Sizeof(); header = new char[nbytes]; buffer = header; Seek(fBEGIN); @@ -621,7 +621,7 @@ void TFile::Init(Bool_t create) //*-* -------------Read keys of the top directory if (fSeekKeys > fBEGIN && fEND <= size) { //normal case. Recover only if file has no keys - TDirectory::ReadKeys(); + TDirectoryFile::ReadKeys(); gDirectory = this; if (!GetNkeys()) Recover(); } else if ((fBEGIN+nbytes == fEND) && (fEND == size)) { @@ -714,8 +714,8 @@ void TFile::Close(Option_t *option) // Delete all supported directories structures from memory // If gDirectory points to this object or any of the nested - // TDirectory, TDirectory::Close will induce the proper cd. - TDirectory::Close(); + // TDirectoryFile, TDirectoryFile::Close will induce the proper cd. + TDirectoryFile::Close(); if (IsWritable()) { TFree *f1 = (TFree*)fFree->First(); @@ -796,7 +796,7 @@ void TFile::Delete(const char *namecycle) if (gDebug) Info("Delete", "deleting name = %s", namecycle); - TDirectory::Delete(namecycle); + TDirectoryFile::Delete(namecycle); } //______________________________________________________________________________ @@ -1071,7 +1071,7 @@ void TFile::ls(Option_t *option) const TROOT::IndentLevel(); cout <<ClassName()<<"**\t\t"<<GetName()<<"\t"<<GetTitle()<<endl; TROOT::IncreaseDirLevel(); - TDirectory::ls(option); + TDirectoryFile::ls(option); TROOT::DecreaseDirLevel(); } @@ -1715,7 +1715,7 @@ Int_t TFile::Write(const char *, Int_t opt, Int_t bufsiz) } fMustFlush = kFALSE; - Int_t nbytes = TDirectory::Write(0, opt, bufsiz); // Write directory tree + Int_t nbytes = TDirectoryFile::Write(0, opt, bufsiz); // Write directory tree WriteStreamerInfo(); WriteFree(); // Write free segments linked list WriteHeader(); // Now write file header diff --git a/io/src/TKey.cxx b/io/src/TKey.cxx index 609b9ee78e5ce3da7e0cc747ba8b688b29a935e2..cf90ee08e28a2bf57b6c52417fdf8d93a4aef402 100644 --- a/io/src/TKey.cxx +++ b/io/src/TKey.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.62 2007/01/12 16:03:15 brun Exp $ +// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.63 2007/01/19 16:47:59 brun Exp $ // Author: Rene Brun 28/12/94 /************************************************************************* @@ -40,7 +40,7 @@ // - to write a new ntuple buffer // // // // The structure of a file is shown in TFile::TFile. // -// The structure of a directory is shown in TDirectory::TDirectory. // +// The structure of a directory is shown in TDirectoryFile ctor. // // The TKey class is used by the TBasket class. // // See also TTree. // // // @@ -49,7 +49,7 @@ #include "Riostream.h" #include "TROOT.h" #include "TClass.h" -#include "TDirectory.h" +#include "TDirectoryFile.h" #include "TFile.h" #include "TKey.h" #include "TBufferFile.h" @@ -142,7 +142,7 @@ TKey::TKey(TDirectory* motherDir) : TNamed(), fDatime((UInt_t)0) TKey::TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir) : TNamed() { // Create a TKey object to read keys. - // Constructor called by TDirectory::ReadKeys and by TFile::TFile. + // Constructor called by TDirectoryFile::ReadKeys and by TFile::TFile. // A TKey object is created to read the keys structure itself. Build(motherDir, "", pointer); @@ -367,7 +367,7 @@ void TKey::Browse(TBrowser *b) { // Read object from disk and call its Browse() method. // If object with same name already exist in memory delete it (like - // TDirectory::Get() is doing), except when the key references a + // TDirectoryFile::Get() is doing), except when the key references a // folder in which case we don't want to re-read the folder object // since it might contain new objects not yet saved. @@ -737,8 +737,8 @@ TObject *TKey::ReadObj() if (gROOT->GetForceStyle()) tobj->UseCurrentStyle(); - if (cl == TDirectory::Class()) { - TDirectory *dir = dynamic_cast<TDirectory*>(tobj); + if (cl == TDirectoryFile::Class()) { + TDirectory *dir = dynamic_cast<TDirectoryFile*>(tobj); dir->SetName(GetName()); dir->SetTitle(GetTitle()); dir->SetMother(fMotherDir); @@ -873,8 +873,8 @@ void *TKey::ReadObjectAny(const TClass* expectedClass) // See similar adjustments in ReadObj if (gROOT->GetForceStyle()) tobj->UseCurrentStyle(); - if (cl == TDirectory::Class()) { - TDirectory *dir = dynamic_cast<TDirectory*>(tobj); + if (cl == TDirectoryFile::Class()) { + TDirectory *dir = dynamic_cast<TDirectoryFile*>(tobj); dir->SetName(GetName()); dir->SetTitle(GetTitle()); gDirectory->Append(dir); diff --git a/io/src/TMapFile.cxx b/io/src/TMapFile.cxx index 484de1ee08fb97bb071202eea3d304fa95fd73d9..bc5bcaf3279bf0d09f2719b00b183857d4323b54 100644 --- a/io/src/TMapFile.cxx +++ b/io/src/TMapFile.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TMapFile.cxx,v 1.23 2007/01/15 12:51:25 brun Exp $ +// @(#)root/base:$Name: $:$Id: TMapFile.cxx,v 1.24 2007/01/19 16:47:59 brun Exp $ // Author: Fons Rademakers 08/07/97 /************************************************************************* @@ -89,7 +89,7 @@ #include "TMapFile.h" #include "TKeyMapFile.h" -#include "TDirectory.h" +#include "TDirectoryFile.h" #include "TBrowser.h" #include "TString.h" #include "TSystem.h" @@ -519,7 +519,7 @@ void TMapFile::InitDirectory() // Create the directory associated to this mapfile gDirectory = 0; - fDirectory = new TDirectory(); + fDirectory = new TDirectoryFile(); fDirectory->SetName(GetName()); fDirectory->SetTitle(GetTitle()); fDirectory->Build(); diff --git a/sql/src/TKeySQL.cxx b/sql/src/TKeySQL.cxx index 97047c6eeb028732b50cb496de28ed6acc4ebafe..074744e4e8c3a21124a5887f247365aaee4ff4f1 100644 --- a/sql/src/TKeySQL.cxx +++ b/sql/src/TKeySQL.cxx @@ -1,4 +1,4 @@ -// @(#)root/sql:$Name: $:$Id: TKeySQL.cxx,v 1.9 2006/05/22 08:55:58 brun Exp $ +// @(#)root/sql:$Name: $:$Id: TKeySQL.cxx,v 1.10 2006/06/22 08:21:22 brun Exp $ // Author: Sergey Linev 20/11/2005 /************************************************************************* @@ -22,7 +22,6 @@ #include "TROOT.h" #include "TClass.h" #include "TBrowser.h" -#include "TDirectory.h" #include "Riostream.h" #include "TSQLResult.h" @@ -210,8 +209,8 @@ TObject* TKeySQL::ReadObj() if (tobj!=0) { if (gROOT->GetForceStyle()) tobj->UseCurrentStyle(); - if (tobj->IsA() == TDirectory::Class()) { - TDirectory *dir = (TDirectory*) tobj; + if (tobj->IsA() == TDirectoryFile::Class()) { + TDirectoryFile *dir = (TDirectoryFile*) tobj; dir->SetName(GetName()); dir->SetTitle(GetTitle()); dir->SetSeekDir(GetDBKeyId()); diff --git a/sql/src/TSQLFile.cxx b/sql/src/TSQLFile.cxx index 30d1e04dceb7f2fb19523c430f485a1c6e2dfd99..0a738dc74a57eb512f6b3cdc3debd23a25472705 100644 --- a/sql/src/TSQLFile.cxx +++ b/sql/src/TSQLFile.cxx @@ -1,4 +1,4 @@ -// @(#)root/sql:$Name: $:$Id: TSQLFile.cxx,v 1.14 2006/06/25 18:43:24 brun Exp $ +// @(#)root/sql:$Name: $:$Id: TSQLFile.cxx,v 1.15 2006/06/27 14:36:27 brun Exp $ // Author: Sergey Linev 20/11/2005 /************************************************************************* @@ -346,7 +346,7 @@ TSQLFile::TSQLFile(const char* dbname, Option_t* option, const char* user, const gDirectory = 0; SetName(dbname); SetTitle("TFile interface to SQL DB"); - TDirectory::Build(); + TDirectoryFile::Build(); fFile = this; if (strstr(dbname,"oracle://")!=0) { @@ -691,7 +691,7 @@ void TSQLFile::Close(Option_t *option) } // Delete all supported directories structures from memory - TDirectory::Close(); + TDirectoryFile::Close(); cd(); // Close() sets gFile = 0 if (cursav) @@ -860,7 +860,7 @@ Bool_t TSQLFile::WriteSpecialObject(Long64_t keyid, TObject* obj, const char* na { // write special kind of object like streamer infos or file itself // keys for that objects should exist in tables but not indicated in list of keys, -// therefore users can not get them with TDirectory::Get() method +// therefore users can not get them with TDirectoryFile::Get() method DeleteKeyFromDB(keyid); if (obj==0) return kTRUE; @@ -2626,7 +2626,7 @@ void TSQLFile::DirWriteHeader(TDirectory* dir) { // Update dir header in the file - TSQLClassInfo* sqlinfo = FindSQLClassInfo("TDirectory",TDirectory::Class()->GetClassVersion()); + TSQLClassInfo* sqlinfo = FindSQLClassInfo("TDirectory",TDirectoryFile::Class()->GetClassVersion()); if (sqlinfo==0) return; // try to identify key with data for our directory @@ -2636,10 +2636,10 @@ void TSQLFile::DirWriteHeader(TDirectory* dir) const char* valuequote = SQLValueQuote(); const char* quote = SQLIdentifierQuote(); - TString timeC = dir->GetCreationDate().AsSQLString(); + TString timeC = fDatimeC.AsSQLString(); TSQLStructure::AddStrBrackets(timeC, valuequote); - TString timeM = dir->GetModificationDate().AsSQLString(); + TString timeM = fDatimeM.AsSQLString(); TSQLStructure::AddStrBrackets(timeM, valuequote); TString uuid = dir->GetUUID().AsString(); diff --git a/treeplayer/src/TFileDrawMap.cxx b/treeplayer/src/TFileDrawMap.cxx index f019e28d3c39357628add38b6b248810baf1221e..21c487d9f7990432086bfe863ccbb1ea382ce0f2 100644 --- a/treeplayer/src/TFileDrawMap.cxx +++ b/treeplayer/src/TFileDrawMap.cxx @@ -1,4 +1,4 @@ -// @(#)root/treeplayer:$Name: $:$Id: TFileDrawMap.cxx,v 1.7 2006/02/03 21:55:39 pcanal Exp $ +// @(#)root/treeplayer:$Name: $:$Id: TFileDrawMap.cxx,v 1.8 2006/09/11 09:15:11 brun Exp $ // Author: Rene Brun 15/01/2003 /************************************************************************* @@ -397,7 +397,7 @@ Bool_t TFileDrawMap::GetObjectInfoDir(TDirectory *dir, Int_t px, Int_t py, char TDirectory *curdir = gDirectory; TClass *cl = gROOT->GetClass(key->GetClassName()); // a TDirectory ? - if (cl && cl == TDirectory::Class()) { + if (cl && cl == TDirectoryFile::Class()) { curdir->cd(key->GetName()); TDirectory *subdir = gDirectory; Bool_t gotInfo = GetObjectInfoDir(subdir, px, py, info); @@ -559,7 +559,7 @@ void TFileDrawMap::PaintDir(TDirectory *dir, const char *keys) TString s = key->GetName(); if (strcmp(fKeys.Data(),key->GetName()) && s.Index(re) == kNPOS) continue; // a TDirectory ? - if (cl && cl == TDirectory::Class()) { + if (cl && cl == TDirectoryFile::Class()) { TDirectory *curdir = gDirectory; gDirectory->cd(key->GetName()); TDirectory *subdir = gDirectory; diff --git a/xml/src/TKeyXML.cxx b/xml/src/TKeyXML.cxx index 45a00a1f7e5ef18fd382f101635b51d21c587024..e03e612e623cb16973e8dbd71d2411d1c8b16e2c 100644 --- a/xml/src/TKeyXML.cxx +++ b/xml/src/TKeyXML.cxx @@ -1,4 +1,4 @@ -// @(#)root/xml:$Name: $:$Id: TKeyXML.cxx,v 1.8 2006/06/22 08:21:22 brun Exp $ +// @(#)root/xml:$Name: $:$Id: TKeyXML.cxx,v 1.9 2007/01/20 19:29:35 brun Exp $ // Author: Sergey Linev, Rene Brun 10.05.2004 /************************************************************************* @@ -252,8 +252,8 @@ TObject* TKeyXML::ReadObj() if (tobj!=0) { if (gROOT->GetForceStyle()) tobj->UseCurrentStyle(); - if (tobj->IsA() == TDirectory::Class()) { - TDirectory *dir = (TDirectory*) tobj; + if (tobj->IsA() == TDirectoryFile::Class()) { + TDirectoryFile *dir = (TDirectoryFile*) tobj; dir->SetName(GetName()); dir->SetTitle(GetTitle()); dir->SetSeekDir(GetKeyId()); diff --git a/xml/src/TXMLFile.cxx b/xml/src/TXMLFile.cxx index c818bb94af9ff5ad621d58861fb7b07a583caf8b..53a383ff127f5c3984f44462030e391477e52737 100644 --- a/xml/src/TXMLFile.cxx +++ b/xml/src/TXMLFile.cxx @@ -1,4 +1,4 @@ -// @(#)root/xml:$Name: $:$Id: TXMLFile.cxx,v 1.22 2006/06/27 14:36:28 brun Exp $ +// @(#)root/xml:$Name: $:$Id: TXMLFile.cxx,v 1.23 2006/10/05 10:28:49 brun Exp $ // Author: Sergey Linev, Rene Brun 10.05.2004 /************************************************************************* @@ -37,8 +37,8 @@ // TFile::Open("file.xml","recreate"); // TFile::Open returns a TXMLFile object. When a XML file is open in write mode, // one can use the normal TObject::Write to write an object in the file. -// Alternatively one can use the new functions TDirectory::WriteObject and -// TDirectory::WriteObjectAny to write a TObject* or any class not deriving +// Alternatively one can use the new functions TDirectoryFile::WriteObject and +// TDirectoryFile::WriteObjectAny to write a TObject* or any class not deriving // from TObject. // // example of a session saving a histogram to a XML file @@ -146,7 +146,7 @@ TXMLFile::TXMLFile(const char* filename, Option_t* option, const char* title, In gDirectory = 0; SetName(filename); SetTitle(title); - TDirectory::Build(this, 0); + TDirectoryFile::Build(this, 0); fD = -1; fFile = this; @@ -345,7 +345,7 @@ void TXMLFile::Close(Option_t *option) } // Delete all supported directories structures from memory - TDirectory::Close(); + TDirectoryFile::Close(); cd(); // Close() sets gFile = 0 if (cursav)