97 ::Error(
"TDirectoryFile",
"directory name (%s) cannot contain a slash",
name);
102 ::Error(
"TDirectoryFile",
"directory name cannot be \"\"");
113 if (!
f->IsWritable())
return;
115 Error(
"TDirectoryFile",
"An object with name %s exists already",
name);
122 Error(
"TDirectoryFile",
"Invalid class name: %s",classname);
200 Info(
"~TDirectoryFile",
"dtor called for %s",
GetName());
212 if (!obj || !
fList)
return;
229 Error(
"AppendKey",
"TDirectoryFile not initialized yet.");
255 return oldkey->GetCycle() + 1;
268 TKey *key =
nullptr, *
keyo =
nullptr;
274 while ((obj =
nextin())) {
280 while ((key = (
TKey *) next())) {
390 char *
pobj = (
char*)obj->
IsA()->New();
391 if (!
pobj)
return nullptr;
398 Fatal(
"CloneObject",
"Incorrect detection of the inheritance from TObject for class %s.\n",
399 obj->
IsA()->GetName());
417 ((
TObject*)obj)->Streamer(buffer);
450 while ((
f = (
TFile*)next())) {
485 char *path =
new char[
nch+1]; path[0] = 0;
487 char *s = (
char*)
strchr(path,
':');
496 if (
f && 0 ==
url->Compare(
f->GetFile()->GetEndpointUrl())) {
507 delete [] path;
return result;
510 delete [] path;
return nullptr;
515 if (path[0] ==
'/') {
519 delete [] path;
return result;
525 if (!
strcmp(path,
"..")) {
527 delete [] path;
return result;
531 if (printError)
Error(
funcname,
"Unknown directory %s", path);
532 delete [] path;
return nullptr;
535 delete [] path;
return obj;
546 delete [] path;
return result;
551 delete [] path;
return nullptr;
555 delete [] path;
return result;
635 Info(
"Delete",
"Call for this = %s namecycle = %s",
656 if (cycle >= 9999 ) {
661 s =
idcur->GetName();
688 if (cycle != 9999 ) {
806 Error(
"FindKeyAny",
"Unexpected type of TDirectoryFile::fKeys!");
813 && (cycle == 9999 || cycle >= key->GetCycle())) {
823 while ((key = (
TKey *) next())) {
858 Error(
"FindObjectAny",
"Unexpected type of TDirectoryFile::fKeys!");
865 && (cycle == 9999 || cycle >= key->GetCycle())) {
866 return key->ReadObj();
874 while ((key = (
TKey *) next())) {
946 if (
name[i] ==
'/') {
965 }
else if (cycle == 9999) {
979 Error(
"Get",
"Unexpected type of TDirectoryFile::fKeys!");
986 && (cycle == 9999 || cycle == key->GetCycle())) {
988 return key->ReadObj();
1051 Error(
"GetObjectChecked",
"The provided key name is invalid.");
1060 for (
Int_t i =
nch-1; i > 0; i--) {
1061 if (
name[i] ==
'/') {
1085 }
else if (cycle == 9999) {
1102 Error(
"GetObjectChecked",
"Unexpected type of TDirectoryFile::fKeys!");
1109 && (cycle == 9999 || cycle == key->GetCycle())) {
1139 if (!
fKeys)
return nullptr;
1143 Error(
"GetKey",
"Unexpected type of TDirectoryFile::fKeys!");
1150 && (cycle == 9999 || cycle >= key->GetCycle())) {
1193 }
else if (!opt.
IsNull()) {
1217 bool first = (
lnk->Prev() ==
nullptr) || (s !=
lnk->Prev()->GetObject()->GetName());
1218 bool hasbackup = (
lnk->Next() !=
nullptr) && (s ==
lnk->Next()->GetObject()->GetName());
1252 if (!
name || !title || !
name[0])
return nullptr;
1253 if (!title[0]) title =
name;
1258 Error(
"mkdir",
"An object with name %s exists already",
name);
1269 if (!
tmpdir)
return nullptr;
1300 while ((key = (
TKey*)prev())) {
1337 while ((key = (
TKey *) next())) {
1344 if ((
dir!=0) && (
strcmp(opt,
"dirs*")==0))
dir->ReadAll(
"dirs*");
1347 while ((key = (
TKey *) next())) {
1395 char *header =
new char[
nbytes];
1434 key =
new TKey(
this);
1437 Error(
"ReadKeys",
"reading illegal key, exiting after %d keys",i);
1443 Error(
"ReadKeys",
"reading illegal key, exiting after %d keys",i);
1468 if (!
fFile) {
Error(
"ReadTObject",
"No file open");
return 0; }
1471 Error(
"ReadTObject",
"Unexpected type of TDirectoryFile::fKeys!");
1478 return key->Read(obj);
1483 Error(
"ReadTObject",
"Key not found");
1526 while ((
idcur = next())) {
1601 if (
fname.Index(
".json") > 0) {
1606 if (!
local)
return 0;
1611 obj->
Info(
"SaveAs",
"ROOT file %s has been created",
fname.Data());
1695 while ((
idcur = next())) {
1727 if (
b.IsReading()) {
1740 b.ClassMember(
"CreateTime",
"TString");
1745 b.ClassMember(
"ModifyTime",
"TString");
1750 b.ClassMember(
"UUID",
"TString");
1794 b.ClassMember(
"CreateTime",
"TString");
1798 b.ClassMember(
"ModifyTime",
"TString");
1803 b.ClassMember(
"UUID",
"TString");
1848 while ((obj=next())) {
1862 Error(
"Write const",
"A const TDirectory object should not be saved. We try to proceed anyway.");
1915 const char *
objname =
"no name specified";
1918 Error(
"WriteTObject",
"The current directory (%s) is not associated with a file. The object (%s) has not been written.",
GetName(),
objname);
2030 Error(
"WriteObjectAny",
"Unknown class: %s",classname);
2033 cl =
info->GetClass();
2054 if (!
fFile)
return 0;
2057 Error(
"WriteObject",
"Unknown type for %s, it can not be written.",
name);
2071 const char *className = cl->
GetName();
2079 Error(
"WriteObjectAny",
2080 "The class requested (%s) for the key name \"%s\""
2081 " is an instance of an stl collection and does not have a compiled CollectionProxy."
2082 " Please generate the dictionary for this collection (%s). No data will be written.",
2083 className,
oname, className);
2147 if (!
f->IsBinary()) {
2149 f->DirWriteHeader(
this);
2154 char *header =
new char[
nbytes];
2155 char *buffer = header;
2161 f->WriteBuffer(header,
nbytes);
2162 if (
f->MustFlush())
f->Flush();
2176 if (!
f->IsBinary()) {
2177 f->DirWriteKeys(
this);
2191 while ((key = (
TKey*)next())) {
2202 while ((key = (
TKey*)next())) {
void frombuf(char *&buf, Bool_t *x)
void tobuf(char *&buf, Bool_t x)
const Bool_t kIterBackward
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void reg
R__EXTERN TVirtualMutex * gROOTMutex
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD(mutex)
Using a TBrowser one can browse all ROOT objects.
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
void MapObject(const TObject *obj, UInt_t offset=1) override
Add object to the fMap container.
void ResetMap() override
Delete existing fMap and reset map counter.
static Int_t ExportToFile(const char *filename, const TObject *obj, const char *option=nullptr)
Convert object into JSON and store in text file Returns size of the produce file Used in TObject::Sav...
Buffer base class used for serializing objects.
void SetBufferOffset(Int_t offset=0)
void SetReadMode()
Set buffer in read mode.
TClass instances represent classes, structs and namespaces in the ROOT type system.
void BuildRealData(void *pointer=nullptr, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual bool UseRWLock(Bool_t enable=true)
Set this collection to use a RW lock upon access, making it thread safe.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
void FillBuffer(char *&buffer)
Encode Date/Time into buffer, used by I/O system.
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
virtual void Streamer(TBuffer &)
Stream a object of type TDatime.
void Set()
Set Date/Time to current time as reported by the system.
void ReadBuffer(char *&buffer)
Decode Date/Time from output buffer, used by I/O system.
A ROOT file is structured in Directories (like a file system).
void SetBufferSize(Int_t bufsize) override
Set the default buffer size when creating new TKeys.
void SetTRefAction(TObject *ref, TObject *parent) override
Find the action to be executed in the dictionary of the parent class and store the corresponding exec...
void Close(Option_t *option="") override
Delete all objects from memory and directory structure itself.
Bool_t cd() override
Change current directory to "this" directory.
TFile * fFile
Pointer to current file in memory.
void Browse(TBrowser *b) override
Browse the content of the directory.
void Append(TObject *obj, Bool_t replace=kFALSE) override
Append object to this directory.
void SaveSelf(Bool_t force=kFALSE) override
Save Directory keys and header.
Bool_t IsWritable() const override
void Streamer(TBuffer &) override
Stream a class object.
void Delete(const char *namecycle="") override
Delete Objects or/and keys in a directory.
virtual void ResetAfterMerge(TFileMergeInfo *)
Reset the TDirectory after its content has been merged into another Directory.
Int_t AppendKey(TKey *key) override
Insert key in the linked list of keys of this directory.
Int_t ReadKeys(Bool_t forceRead=kTRUE) override
Read the linked list of keys.
TDatime fDatimeM
Date and time of last modification.
void * GetObjectUnchecked(const char *namecycle) override
Return pointer to object identified by namecycle.
TKey * FindKey(const char *keyname) const override
Find key with name keyname in the current directory.
TKey * GetKey(const char *name, Short_t cycle=9999) const override
Return pointer to key with name,cycle.
void * GetObjectChecked(const char *namecycle, const char *classname) override
See documentation of TDirectoryFile::GetObjectCheck(const char *namecycle, const TClass *cl)
void InitDirectoryFile(TClass *cl=nullptr)
Initialize the key associated with this directory (and the related data members.
void Purge(Short_t nkeep=1) override
Purge lowest key cycles in a directory.
void Save() override
Save recursively all directory keys and headers.
~TDirectoryFile() override
Destructor.
TObject * FindObjectAnyFile(const char *name) const override
Scan the memory lists of all files for an object with name.
Int_t fNbytesKeys
Number of bytes for the keys.
Bool_t fModified
True if directory has been modified.
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
TList * GetListOfKeys() const override
void CleanTargets()
Clean the pointers to this object (gDirectory, TContext, etc.)
TObject * FindObjectAny(const char *name) const override
Find object by name in the list of memory objects of the current directory or its sub-directories.
Long64_t fSeekKeys
Location of Keys record on file.
void WriteKeys() override
Write Keys linked list on the file.
TFile * GetFile() const override
Int_t fBufferSize
Default buffer size to create new TKeys.
Int_t Sizeof() const override
Return the size in bytes of the directory header.
TObject * CloneObject(const TObject *obj, Bool_t autoadd=kTRUE) override
Make a clone of an object using the Streamer facility.
TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory") override
Find a directory named "apath".
Long64_t fSeekParent
Location of parent directory on file.
Int_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Int_t bufsize=0) override
Write object from pointer of class classname in this directory.
void BuildDirectoryFile(TFile *motherFile, TDirectory *motherDir)
Initialise directory to defaults.
void rmdir(const char *name) override
Removes subdirectory from the directory.
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write all objects in memory to disk.
Long64_t fSeekDir
Location of directory on file.
Int_t fNbytesName
Number of bytes in TNamed at creation time.
TDatime fDatimeC
Date and time when directory is created.
Bool_t fWritable
True if directory is writable.
Int_t WriteTObject(const TObject *obj, const char *name=nullptr, Option_t *option="", Int_t bufsize=0) override
Write object obj to this directory.
Int_t ReadTObject(TObject *obj, const char *keyname) override
Read object with keyname from the current directory.
TFile * OpenFile(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0) override
Interface to TFile::Open.
Int_t GetBufferSize() const override
Return the buffer size to create new TKeys.
Int_t SaveObjectAs(const TObject *obj, const char *filename="", Option_t *option="") const override
Save object in filename.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
static constexpr Version_t Class_Version()
TDirectoryFile()
Default TDirectoryFile constructor.
TKey * FindKeyAny(const char *keyname) const override
Find key with name keyname in the current directory or its subdirectories.
void FillBuffer(char *&buffer) override
Encode directory header into output buffer.
void WriteDirHeader() override
Overwrite the Directory header record.
void SetWritable(Bool_t writable=kTRUE) override
Set the new value of fWritable recursively.
TClass * IsA() const override
void ReadAll(Option_t *option="") override
Read objects from a ROOT file directory into memory.
TList * fKeys
Pointer to keys list in memory.
void ls(Option_t *option="") const override
List Directory contents.
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
virtual TList * GetList() const
void CleanTargets()
Clean the pointers to this object (gDirectory, TContext, etc.).
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
static void DecodeNameCycle(const char *namecycle, char *name, Short_t &cycle, const size_t namesize=0)
Decode a namecycle "aap;2" into name "aap" and cycle "2".
TObject * FindObject(const char *name) const override
Find object by name in the list of memory objects.
virtual Bool_t cd()
Change current directory to "this" directory.
TDirectory * GetMotherDir() const
void GetObject(const char *namecycle, T *&ptr)
Get an object with proper type checking.
virtual TObject * FindObjectAny(const char *name) const
Find object by name in the list of memory objects of the current directory or its sub-directories.
Streamer around an arbitrary STL like container, which implements basic container functionality.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
virtual Int_t DirReadKeys(TDirectory *)
TList * GetListOfFree() const
Int_t GetBestBuffer() const
Return the best buffer size of objects on this file.
virtual TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize)
Creates key for object and converts data to buffer.
virtual Long64_t GetSize() const
Returns the current file size.
virtual Long64_t GetEND() const
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
static TFile *& CurrentFile()
Return the current ROOT file if any.
virtual const TUrl * GetEndpointUrl() const
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Book space in a file, create I/O buffers, to fill them, (un)compress them.
void Delete(Option_t *option="") override
Delete an object from the file.
virtual Long64_t GetSeekKey() const
Int_t Sizeof() const override
Return the size in bytes of the key header structure.
Short_t GetKeep() const
Returns the "KEEP" status.
virtual const char * GetClassName() const
void ReadKeyBuffer(char *&buffer)
Decode input buffer.
virtual Long64_t GetSeekPdir() const
void SetMotherDir(TDirectory *dir)
virtual void ls(Bool_t current) const
List Key contents.
Short_t GetCycle() const
Return cycle number associated to this key.
virtual TObject * ReadObj()
To read a TObject* from the file.
virtual Int_t WriteFile(Int_t cycle=1, TFile *f=nullptr)
Write the encoded object supported by this key.
virtual char * GetBuffer() const
void FillBuffer(char *&buffer) override
Encode key header into output buffer.
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
void AddBefore(const TObject *before, TObject *obj) override
Insert object before object before in the list.
virtual TObjLink * FirstLink() const
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
This class implements a shared memory region mapped to a file.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Wrapper around a TObject so it can be stored in a TList.
Mother of all ROOT objects.
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
virtual const char * GetName() const
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
@ kOnlyPrepStep
Used to request that the class specific implementation of TObject::Write just prepare the objects to ...
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual TClass * IsA() const
virtual void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
@ kCanDelete
if object in a list can be deleted
@ kIsReferenced
if object is referenced by a TRef or TRefArray
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Regular expression class.
Describes a persistent version of a class.
void ToLower()
Change string to lower-case.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
virtual void Streamer(TBuffer &)
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
void StreamerV1(TBuffer &b)
Stream UUID from input buffer.
Abstract Interface class describing Streamer information for one class.
void(* DirAutoAdd_t)(void *, TDirectory *)