ROOT  6.06/09
Reference Guide
TFile.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Rene Brun 28/11/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TFile
13 #define ROOT_TFile
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TFile //
19 // //
20 // ROOT file. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include <atomic>
25 #ifndef ROOT_TDirectoryFile
26 #include "TDirectoryFile.h"
27 #endif
28 #ifndef ROOT_TMap
29 #include "TMap.h"
30 #endif
31 #ifndef ROOT_TUrl
32 #include "TUrl.h"
33 #endif
34 
35 class TFree;
36 class TArrayC;
37 class TArchiveFile;
38 class TFileOpenHandle;
39 class TFileCacheRead;
40 class TFileCacheWrite;
41 class TProcessID;
42 class TStopwatch;
43 class TFilePrefetch;
44 
45 class TFile : public TDirectoryFile {
46  friend class TDirectoryFile;
47  friend class TFilePrefetch;
48 
49 public:
50  /// Asynchronous open request status
51  enum EAsyncOpenStatus { kAOSNotAsync = -1, kAOSFailure = 0,
52  kAOSInProgress = 1, kAOSSuccess = 2 };
53  /// Open timeout constants
54  enum EOpenTimeOut { kInstantTimeout = 0, kEternalTimeout = 999999999 };
55 
56  /// TTreeCache flushing semantics
57  enum ECacheAction { kDisconnect = 0, kDoNotDisconnect = 1 };
58 
59 protected:
60  Double_t fSumBuffer; ///<Sum of buffer sizes of objects written so far
61  Double_t fSum2Buffer; ///<Sum of squares of buffer sizes of objects written so far
62  Long64_t fBytesWrite; ///<Number of bytes written to this file
63  Long64_t fBytesRead; ///<Number of bytes read from this file
64  Long64_t fBytesReadExtra; ///<Number of extra bytes (overhead) read by the readahead buffer
65  Long64_t fBEGIN; ///<First used byte in file
66  Long64_t fEND; ///<Last used byte in file
67  Long64_t fSeekFree; ///<Location on disk of free segments structure
68  Long64_t fSeekInfo; ///<Location on disk of StreamerInfo record
69  Int_t fD; ///<File descriptor
70  Int_t fVersion; ///<File format version
71  Int_t fCompress; ///<Compression level and algorithm
72  Int_t fNbytesFree; ///<Number of bytes for free segments structure
73  Int_t fNbytesInfo; ///<Number of bytes for StreamerInfo record
74  Int_t fWritten; ///<Number of objects written so far
75  Int_t fNProcessIDs; ///<Number of TProcessID written to this file
76  Int_t fReadCalls; ///<Number of read calls ( not counting the cache calls )
77  TString fRealName; ///<Effective real file name (not original url)
78  TString fOption; ///<File options
79  Char_t fUnits; ///<Number of bytes for file pointers
80  TList *fFree; ///<Free segments linked list table
81  TArrayC *fClassIndex; ///<!Index of TStreamerInfo classes written to this file
82  TObjArray *fProcessIDs; ///<!Array of pointers to TProcessIDs
83  Long64_t fOffset; ///<!Seek offset cache
84  TArchiveFile *fArchive; ///<!Archive file from which we read this file
85  TFileCacheRead *fCacheRead; ///<!Pointer to the read cache (if any)
86  TMap *fCacheReadMap; ///<!Pointer to the read cache (if any)
87  TFileCacheWrite *fCacheWrite; ///<!Pointer to the write cache (if any)
88  Long64_t fArchiveOffset; ///<!Offset at which file starts in archive
89  Bool_t fIsArchive : 1; ///<!True if this is a pure archive file
90  Bool_t fNoAnchorInName : 1; ///<!True if we don't want to force the anchor to be appended to the file name
91  Bool_t fIsRootFile : 1; ///<!True is this is a ROOT file, raw file otherwise
92  Bool_t fInitDone : 1; ///<!True if the file has been initialized
93  Bool_t fMustFlush : 1; ///<!True if the file buffers must be flushed
94  Bool_t fIsPcmFile : 1; ///<!True if the file is a ROOT pcm file.
95  TFileOpenHandle *fAsyncHandle; ///<!For proper automatic cleanup
96  EAsyncOpenStatus fAsyncOpenStatus; ///<!Status of an asynchronous open request
97  TUrl fUrl; ///<!URL of file
98 
99  TList *fInfoCache; ///<!Cached list of the streamer infos in this file
100  TList *fOpenPhases; ///<!Time info about open phases
101 
102  static TList *fgAsyncOpenRequests; //List of handles for pending open requests
103 
104  static TString fgCacheFileDir; ///<Directory where to locally stage files
105  static Bool_t fgCacheFileDisconnected; ///<Indicates, we trust in the files in the cache dir without stat on the cached file
106  static Bool_t fgCacheFileForce; ///<Indicates, to force all READ to CACHEREAD
107  static UInt_t fgOpenTimeout; ///<Timeout for open operations in ms - 0 corresponds to blocking i/o
108  static Bool_t fgOnlyStaged ; ///<Before the file is opened, it is checked, that the file is staged, if not, the open fails
109 
110  static std::atomic<Long64_t> fgBytesWrite; ///<Number of bytes written by all TFile objects
111  static std::atomic<Long64_t> fgBytesRead; ///<Number of bytes read by all TFile objects
112  static std::atomic<Long64_t> fgFileCounter; ///<Counter for all opened files
113  static std::atomic<Int_t> fgReadCalls; ///<Number of bytes read from all TFile objects
114  static Int_t fgReadaheadSize; ///<Readahead buffer size
115  static Bool_t fgReadInfo; ///<if true (default) ReadStreamerInfo is called when opening a file
117  virtual void Init(Bool_t create);
119  Int_t ReadBufferViaCache(char *buf, Int_t len);
120  Int_t WriteBufferViaCache(const char *buf, Int_t len);
121 
122  // Creating projects
123  Int_t MakeProjectParMake(const char *packname, const char *filename);
124  Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir);
125 
126  // Interface to basic system I/O routines
127  virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
128  virtual Int_t SysClose(Int_t fd);
129  virtual Int_t SysRead(Int_t fd, void *buf, Int_t len);
130  virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
131  virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
132  virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
133  virtual Int_t SysSync(Int_t fd);
134 
135  // Interface for text-based TDirectory I/O
136  virtual Long64_t DirCreateEntry(TDirectory*) { return 0; }
137  virtual Int_t DirReadKeys(TDirectory*) { return 0; }
138  virtual void DirWriteKeys(TDirectory*) {}
139  virtual void DirWriteHeader(TDirectory*) {}
140 
141 private:
142  TFile(const TFile &); //Files cannot be copied
143  void operator=(const TFile &);
144 
145  static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch);
146  static TFile *OpenFromCache(const char *name, Option_t * = "",
147  const char *ftitle = "", Int_t compress = 1,
148  Int_t netopt = 0);
149 
150 public:
151  /// TFile status bits. BIT(13) is taken up by TObject
152  enum EStatusBits {
153  kRecovered = BIT(10),
154  kHasReferences = BIT(11),
155  kDevNull = BIT(12),
156  kWriteError = BIT(14),
157  kBinaryFile = BIT(15),
158  kRedirected = BIT(16)
159  };
160  enum ERelativeTo { kBeg = 0, kCur = 1, kEnd = 2 };
161  enum { kStartBigFile = 2000000000 };
162  /// File type
163  enum EFileType { kDefault = 0, kLocal = 1, kNet = 2, kWeb = 3, kFile = 4, kMerge = 5};
164 
165  TFile();
166  TFile(const char *fname, Option_t *option="", const char *ftitle="", Int_t compress=1);
167  virtual ~TFile();
168  virtual void Close(Option_t *option=""); // *MENU*
169  virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
170  virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE,UInt_t buffersize = 1000000);
171  virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize);
172  virtual TKey* CreateKey(TDirectory* mother, const void* obj, const TClass* cl,
173  const char* name, Int_t bufsize);
174  static TFile *&CurrentFile(); // Return the current file for this thread.
175  virtual void Delete(const char *namecycle="");
176  virtual void Draw(Option_t *option="");
177  virtual void DrawMap(const char *keys="*",Option_t *option=""); // *MENU*
178  virtual void FillBuffer(char *&buffer);
179  virtual void Flush();
180  TArchiveFile *GetArchive() const { return fArchive; }
181  Long64_t GetArchiveOffset() const { return fArchiveOffset; }
182  Int_t GetBestBuffer() const;
183  virtual Int_t GetBytesToPrefetch() const;
184  TFileCacheRead *GetCacheRead(TObject* tree = 0) const;
186  TArrayC *GetClassIndex() const { return fClassIndex; }
188  Int_t GetCompressionLevel() const;
191  virtual Long64_t GetEND() const { return fEND; }
192  virtual Int_t GetErrno() const;
193  virtual void ResetErrno() const;
194  Int_t GetFd() const { return fD; }
195  virtual const TUrl *GetEndpointUrl() const { return &fUrl; }
196  TObjArray *GetListOfProcessIDs() const {return fProcessIDs;}
197  TList *GetListOfFree() const { return fFree; }
198  virtual Int_t GetNfree() const { return fFree->GetSize(); }
199  virtual Int_t GetNProcessIDs() const { return fNProcessIDs; }
200  Option_t *GetOption() const { return fOption.Data(); }
201  virtual Long64_t GetBytesRead() const { return fBytesRead; }
202  virtual Long64_t GetBytesReadExtra() const { return fBytesReadExtra; }
203  virtual Long64_t GetBytesWritten() const;
204  virtual Int_t GetReadCalls() const { return fReadCalls; }
205  Int_t GetVersion() const { return fVersion; }
206  Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes,
207  Int_t &nbytes, Int_t &objlen, Int_t &keylen);
208  virtual Int_t GetNbytesInfo() const {return fNbytesInfo;}
209  virtual Int_t GetNbytesFree() const {return fNbytesFree;}
210  virtual TString GetNewUrl() { return ""; }
211  Long64_t GetRelOffset() const { return fOffset - fArchiveOffset; }
212  virtual Long64_t GetSeekFree() const {return fSeekFree;}
213  virtual Long64_t GetSeekInfo() const {return fSeekInfo;}
214  virtual Long64_t GetSize() const;
215  virtual TList *GetStreamerInfoList();
216  const TList *GetStreamerInfoCache();
217  virtual void IncrementProcessIDs() { fNProcessIDs++; }
218  virtual Bool_t IsArchive() const { return fIsArchive; }
219  Bool_t IsBinary() const { return TestBit(kBinaryFile); }
220  Bool_t IsRaw() const { return !fIsRootFile; }
221  virtual Bool_t IsOpen() const;
222  virtual void ls(Option_t *option="") const;
223  virtual void MakeFree(Long64_t first, Long64_t last);
224  virtual void MakeProject(const char *dirname, const char *classes="*",
225  Option_t *option="new"); // *MENU*
226  virtual void Map(); // *MENU*
227  virtual Bool_t Matches(const char *name);
228  virtual Bool_t MustFlush() const {return fMustFlush;}
229  virtual void Paint(Option_t *option="");
230  virtual void Print(Option_t *option="") const;
231  virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
232  virtual Bool_t ReadBuffer(char *buf, Int_t len);
233  virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
234  virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
235  virtual void ReadFree();
236  virtual TProcessID *ReadProcessID(UShort_t pidf);
237  virtual void ReadStreamerInfo();
238  virtual Int_t Recover();
239  virtual Int_t ReOpen(Option_t *mode);
240  virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
241  virtual void SetCacheRead(TFileCacheRead *cache, TObject* tree = 0, ECacheAction action = kDisconnect);
242  virtual void SetCacheWrite(TFileCacheWrite *cache);
243  virtual void SetCompressionAlgorithm(Int_t algorithm=0);
244  virtual void SetCompressionLevel(Int_t level=1);
245  virtual void SetCompressionSettings(Int_t settings=1);
246  virtual void SetEND(Long64_t last) { fEND = last; }
247  virtual void SetOffset(Long64_t offset, ERelativeTo pos = kBeg);
248  virtual void SetOption(Option_t *option=">") { fOption = option; }
249  virtual void SetReadCalls(Int_t readcalls = 0) { fReadCalls = readcalls; }
250  virtual void ShowStreamerInfo();
251  virtual Int_t Sizeof() const;
252  void SumBuffer(Int_t bufsize);
253  virtual Bool_t WriteBuffer(const char *buf, Int_t len);
254  virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0);
255  virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0) const;
256  virtual void WriteFree();
257  virtual void WriteHeader();
258  virtual UShort_t WriteProcessID(TProcessID *pid);
259  virtual void WriteStreamerInfo();
260 
261  static TFileOpenHandle
262  *AsyncOpen(const char *name, Option_t *option = "",
263  const char *ftitle = "", Int_t compress = 1,
264  Int_t netopt = 0);
265  static TFile *Open(const char *name, Option_t *option = "",
266  const char *ftitle = "", Int_t compress = 1,
267  Int_t netopt = 0);
268  static TFile *Open(TFileOpenHandle *handle);
269 
270  static EFileType GetType(const char *name, Option_t *option = "", TString *prefix = 0);
271 
272  static EAsyncOpenStatus GetAsyncOpenStatus(const char *name);
274  static const TUrl *GetEndpointUrl(const char *name);
275 
276  static Long64_t GetFileBytesRead();
277  static Long64_t GetFileBytesWritten();
278  static Int_t GetFileReadCalls();
279  static Int_t GetReadaheadSize();
280 
281  static void SetFileBytesRead(Long64_t bytes = 0);
282  static void SetFileBytesWritten(Long64_t bytes = 0);
283  static void SetFileReadCalls(Int_t readcalls = 0);
284  static void SetReadaheadSize(Int_t bufsize = 256000);
285  static void SetReadStreamerInfo(Bool_t readinfo=kTRUE);
286  static Bool_t GetReadStreamerInfo();
287 
288  static Long64_t GetFileCounter();
289  static void IncrementFileCounter();
290 
291  static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected = kTRUE,
292  Bool_t forceCacheread = kFALSE);
293  static const char *GetCacheFileDir();
294  static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval = 0);
295  static Bool_t Cp(const char *src, const char *dst, Bool_t progressbar = kTRUE,
296  UInt_t buffersize = 1000000);
297 
298  static UInt_t SetOpenTimeout(UInt_t timeout); // in ms
299  static UInt_t GetOpenTimeout(); // in ms
300  static Bool_t SetOnlyStaged(Bool_t onlystaged);
301  static Bool_t GetOnlyStaged();
302 
303  ClassDef(TFile,8) //ROOT file
304 };
305 
306 #ifndef __CINT__
307 #define gFile (TFile::CurrentFile())
308 
309 #elif defined(__MAKECINT__)
310 // To properly handle the use of gFile in header files (in static declarations)
312 #endif
313 
314 /**
315 \class TFileOpenHandle
316 \ingroup IO
317 Class holding info about the file being opened
318 */
319 class TFileOpenHandle : public TNamed {
320 
321 friend class TFile;
322 friend class TAlienFile;
323 
324 private:
325  TString fOpt; ///< Options
326  Int_t fCompress; ///< Compression level and algorithm
327  Int_t fNetOpt; ///< Network options
328  TFile *fFile; ///< TFile instance of the file being opened
329 
330  TFileOpenHandle(TFile *f) : TNamed("",""), fOpt(""), fCompress(1),
331  fNetOpt(0), fFile(f) { }
332  TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp,
333  Int_t no) : TNamed(n,t), fOpt(o), fCompress(cmp),
334  fNetOpt(no), fFile(0) { }
337 
338  TFile *GetFile() const { return fFile; }
339 
340 public:
341  ~TFileOpenHandle() { }
342 
343  Bool_t Matches(const char *name);
344 
345  const char *GetOpt() const { return fOpt; }
346  Int_t GetCompress() const { return fCompress; }
347  Int_t GetNetOpt() const { return fNetOpt; }
348 };
349 
350 //______________________________________________________________________________
352 {
353  return (fCompress < 0) ? -1 : fCompress / 100;
354 }
355 
356 //______________________________________________________________________________
357 inline Int_t TFile::GetCompressionLevel() const
358 {
359  return (fCompress < 0) ? -1 : fCompress % 100;
360 }
361 
362 //______________________________________________________________________________
364 {
365  return (fCompress < 0) ? -1 : fCompress;
366 }
367 
368 #endif
virtual void Map()
List the contents of a file sequentially.
Definition: TFile.cxx:1448
virtual Int_t GetNProcessIDs() const
Definition: TFile.h:199
virtual void DirWriteKeys(TDirectory *)
Definition: TFile.h:138
virtual Bool_t MustFlush() const
Definition: TFile.h:228
Bool_t fIsArchive
!True if this is a pure archive file
Definition: TFile.h:89
Bool_t fIsPcmFile
!True if the file is a ROOT pcm file.
Definition: TFile.h:94
virtual Long64_t GetSeekFree() const
Definition: TFile.h:212
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive...
Definition: TArchiveFile.h:30
virtual void DrawMap(const char *keys="*", Option_t *option="")
Draw map of objects in this file.
Definition: TFile.cxx:1067
virtual Int_t Recover()
Attempt to recover file if not correctly closed.
Definition: TFile.cxx:1857
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition: TFile.h:85
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TFile.cxx:1279
An array of TObjects.
Definition: TObjArray.h:39
Char_t fUnits
Number of bytes for file pointers.
Definition: TFile.h:79
virtual void ls(Option_t *option="") const
List file contents.
Definition: TFile.cxx:1361
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Return file stat information.
Definition: TFile.cxx:4288
void operator=(const TFile &)
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition: TFile.h:82
Long64_t fBEGIN
First used byte in file.
Definition: TFile.h:65
long long Long64_t
Definition: RtypesCore.h:69
static Bool_t fgReadInfo
if true (default) ReadStreamerInfo is called when opening a file
Definition: TFile.h:115
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system lseek.
Definition: TFile.cxx:4270
Long64_t fBytesWrite
Number of bytes written to this file.
Definition: TFile.h:62
EAsyncOpenStatus
Asynchronous open request status.
Definition: TFile.h:51
virtual Int_t GetErrno() const
Method returning errno. Is overriden in TRFIOFile.
Definition: TFile.cxx:1180
Bool_t IsBinary() const
Definition: TFile.h:219
Long64_t GetRelOffset() const
Definition: TFile.h:211
virtual void FillBuffer(char *&buffer)
Encode file output buffer.
Definition: TFile.cxx:1109
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition: TFile.h:60
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Definition: TFile.h:111
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
Definition: TFile.cxx:1971
float Float_t
Definition: RtypesCore.h:53
Int_t fCompress
Compression level and algorithm.
Definition: TFile.h:71
Int_t GetCompressionAlgorithm() const
Definition: TFile.h:351
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition: TFile.h:81
Bool_t Matches(const char *name)
Return kTRUE if this async request matches the open request specified by 'url'.
Definition: TFile.cxx:4535
static void IncrementFileCounter()
Definition: TFile.cxx:4365
virtual void ReadFree()
Read the FREE linked list.
Definition: TFile.cxx:1751
A cache when reading files over the network.
const char Option_t
Definition: RtypesCore.h:62
TString fOpt
Options.
Definition: TFile.h:325
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
Definition: TFile.cxx:1080
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
Definition: TFile.cxx:2177
static TList * fgAsyncOpenRequests
Definition: TFile.h:102
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TFile.cxx:2064
This class represents a WWW compatible URL.
Definition: TUrl.h:41
virtual void SetEND(Long64_t last)
Definition: TFile.h:246
virtual TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize)
Creates key for object and converts data to buffer.
Definition: TFile.cxx:995
unsigned short UShort_t
Definition: RtypesCore.h:36
Class holding info about the file being opened.
Definition: TFile.h:319
static UInt_t fgOpenTimeout
Timeout for open operations in ms - 0 corresponds to blocking i/o.
Definition: TFile.h:107
TList * GetListOfFree() const
Definition: TFile.h:197
#define BIT(n)
Definition: Rtypes.h:120
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition: TObject.cxx:971
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
Definition: TFile.cxx:2085
virtual void DirWriteHeader(TDirectory *)
Definition: TFile.h:139
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
virtual Long64_t GetBytesWritten() const
Return the total number of bytes written so far to the file.
Definition: TFile.cxx:4311
static void SetFileReadCalls(Int_t readcalls=0)
Definition: TFile.cxx:4359
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition: TFile.cxx:1596
virtual void SetReadCalls(Int_t readcalls=0)
Definition: TFile.h:249
static const char * filename()
TFileOpenHandle(TFile *f)
Definition: TFile.h:330
virtual const TUrl * GetEndpointUrl() const
Definition: TFile.h:195
Basic string class.
Definition: TString.h:137
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval=0)
Try to shrink the cache to the desired size.
Definition: TFile.cxx:4411
virtual Int_t GetNbytesInfo() const
Definition: TFile.h:208
~TFileOpenHandle()
Definition: TFile.h:341
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition: TFile.cxx:2331
Long64_t fBytesReadExtra
Number of extra bytes (overhead) read by the readahead buffer.
Definition: TFile.h:64
virtual Long64_t GetEND() const
Definition: TFile.h:191
ERelativeTo
Definition: TFile.h:160
TList * fInfoCache
!Cached list of the streamer infos in this file
Definition: TFile.h:99
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE)
Specify if the streamerinfos must be read at file opening.
Definition: TFile.cxx:3501
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition: TFile.h:68
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:76
TArchiveFile * fArchive
!Archive file from which we read this file
Definition: TFile.h:84
static void SetReadaheadSize(Int_t bufsize=256000)
Definition: TFile.cxx:4350
Int_t GetBestBuffer() const
Return the best buffer size of objects on this file.
Definition: TFile.cxx:1122
Int_t fNetOpt
Network options.
Definition: TFile.h:327
Bool_t IsRaw() const
Definition: TFile.h:220
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
Definition: TFile.cxx:2229
virtual Bool_t IsArchive() const
Definition: TFile.h:218
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3851
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t buffersize=1000000)
Allows to copy this file to the dst URL.
Definition: TFile.cxx:4749
static void SetFileBytesWritten(Long64_t bytes=0)
Definition: TFile.cxx:4356
const char * Data() const
Definition: TString.h:349
TFileCacheRead * GetCacheRead(TObject *tree=0) const
Return a pointer to the current read cache.
Definition: TFile.cxx:1196
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition: TFile.h:73
TMap * fCacheReadMap
!Pointer to the read cache (if any)
Definition: TFile.h:86
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
Definition: TFile.cxx:1373
TUrl fUrl
!URL of file
Definition: TFile.h:97
Option_t * GetOption() const
Definition: TFile.h:200
Int_t fD
File descriptor.
Definition: TFile.h:69
#define ClassDef(name, id)
Definition: Rtypes.h:254
Service class for TFile.
Definition: TFree.h:29
Int_t GetCompressionLevel() const
Definition: TFile.h:357
static Bool_t GetReadStreamerInfo()
If the streamerinfos are to be read at file opening.
Definition: TFile.cxx:3511
virtual void SetCompressionLevel(Int_t level=1)
See comments for function SetCompressionSettings.
Definition: TFile.cxx:2131
virtual void MakeProject(const char *dirname, const char *classes="*", Option_t *option="new")
Generate source code necessary to access the objects stored in the file.
Definition: TFile.cxx:2504
virtual void WriteFree()
Write FREE linked list on the file.
Definition: TFile.cxx:2355
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TString fRealName
Effective real file name (not original url)
Definition: TFile.h:77
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Definition: TFile.cxx:4319
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=0)
Resolve the file type as a function of the protocol field in 'name'.
Definition: TFile.cxx:4566
static TFile * OpenFromCache(const char *name, Option_t *="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Open a file for reading through the file cache.
Definition: TFile.cxx:3644
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
Definition: TFile.cxx:4328
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:34
virtual TString GetNewUrl()
Definition: TFile.h:210
virtual Long64_t GetSeekInfo() const
Definition: TFile.h:213
virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write().
Definition: TFile.cxx:4259
virtual Int_t GetNbytesFree() const
Definition: TFile.h:209
virtual void IncrementProcessIDs()
Definition: TFile.h:217
virtual Int_t SysSync(Int_t fd)
Interface to system fsync. All arguments like in POSIX fsync().
Definition: TFile.cxx:4297
A doubly linked list.
Definition: TList.h:47
Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen)
Read the logical record header starting at a certain postion.
Definition: TFile.cxx:1233
virtual Long64_t DirCreateEntry(TDirectory *)
Definition: TFile.h:136
virtual Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close().
Definition: TFile.cxx:4242
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
Definition: TFile.cxx:4479
virtual void ShowStreamerInfo()
Show the StreamerInfo of all classes written to this file.
Definition: TFile.cxx:3519
EFileType
File type.
Definition: TFile.h:163
virtual Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read().
Definition: TFile.cxx:4251
Int_t GetFd() const
Definition: TFile.h:194
Long64_t fEND
Last used byte in file.
Definition: TFile.h:66
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open().
Definition: TFile.cxx:4226
virtual void WriteStreamerInfo()
Write the list of TStreamerInfo as a single object in this file The class Streamer description for al...
Definition: TFile.cxx:3561
A ROOT file is structured in Directories (like a file system).
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
Definition: TFile.cxx:2248
virtual void SetOption(Option_t *option=">")
Definition: TFile.h:248
virtual void Delete(const char *namecycle="")
Delete object namecycle.
Definition: TFile.cxx:1046
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
Definition: TFile.cxx:2288
EAsyncOpenStatus fAsyncOpenStatus
!Status of an asynchronous open request
Definition: TFile.h:96
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
TArchiveFile * GetArchive() const
Definition: TFile.h:180
virtual void MakeFree(Long64_t first, Long64_t last)
Mark unused bytes on the file.
Definition: TFile.cxx:1388
static std::atomic< Long64_t > fgFileCounter
Counter for all opened files.
Definition: TFile.h:112
TFile * GetFile() const
Definition: TFile.h:338
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
Definition: TFile.h:110
virtual Int_t DirReadKeys(TDirectory *)
Definition: TFile.h:137
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch)
Print file copy progress.
Definition: TFile.cxx:4721
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
Definition: TFile.h:113
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
virtual void Draw(Option_t *option="")
Fill Graphics Structure and Paint.
Definition: TFile.cxx:1059
virtual TList * GetStreamerInfoList()
Read the list of TStreamerInfo objects written to this file.
Definition: TFile.cxx:1319
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
Definition: TFile.cxx:4336
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition: TFile.cxx:581
EStatusBits
TFile status bits. BIT(13) is taken up by TObject.
Definition: TFile.h:152
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
Definition: TFile.cxx:4969
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition: TFile.cxx:1715
static TFile *& CurrentFile()
Return the current ROOT file if any.
Definition: TFile.cxx:1015
virtual Int_t GetReadCalls() const
Definition: TFile.h:204
Int_t GetCompressionSettings() const
Definition: TFile.h:363
static Bool_t fgOnlyStaged
Before the file is opened, it is checked, that the file is staged, if not, the open fails...
Definition: TFile.h:108
static Bool_t GetOnlyStaged()
Returns staged only flag.
Definition: TFile.cxx:4499
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Definition: TFile.cxx:3384
virtual Long64_t GetBytesRead() const
Definition: TFile.h:201
virtual void Copy(TObject &) const
Copy this to obj.
Definition: TFile.h:169
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition: TFile.h:61
long Long_t
Definition: RtypesCore.h:50
TFile()
File default Constructor.
Definition: TFile.cxx:171
TList * fFree
Free segments linked list table.
Definition: TFile.h:80
virtual Int_t GetSize() const
Definition: TCollection.h:95
Int_t GetCompress() const
Definition: TFile.h:346
double f(double x)
Int_t fNbytesFree
Number of bytes for free segments structure.
Definition: TFile.h:72
static Bool_t fgCacheFileForce
Indicates, to force all READ to CACHEREAD.
Definition: TFile.h:106
TFile * fFile
TFile instance of the file being opened.
Definition: TFile.h:328
double Double_t
Definition: RtypesCore.h:55
static Int_t GetReadaheadSize()
Static function returning the readahead buffer size.
Definition: TFile.cxx:4344
virtual Int_t GetNfree() const
Definition: TFile.h:198
Describe directory structure in memory.
Definition: TDirectory.h:41
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
virtual void Print(Option_t *option="") const
Print all objects in the file.
Definition: TFile.cxx:1532
Bool_t fNoAnchorInName
!True if we don't want to force the anchor to be appended to the file name
Definition: TFile.h:90
static Bool_t fgCacheFileDisconnected
Indicates, we trust in the files in the cache dir without stat on the cached file.
Definition: TFile.h:105
TList * fOpenPhases
!Time info about open phases
Definition: TFile.h:100
virtual Int_t Sizeof() const
Return the size in bytes of the file header.
Definition: TFile.cxx:2209
TString fOption
File options.
Definition: TFile.h:78
The prefetching mechanism uses two classes (TFilePrefetch and TFPBlock) to prefetch in advance a bloc...
Definition: TFilePrefetch.h:53
Bool_t fMustFlush
!True if the file buffers must be flushed
Definition: TFile.h:93
Float_t GetCompressionFactor()
Return the file compression factor.
Definition: TFile.cxx:1136
TFileOpenHandle & operator=(const TFileOpenHandle &)
Bool_t fIsRootFile
!True is this is a ROOT file, raw file otherwise
Definition: TFile.h:91
#define name(a, b)
Definition: linkTestLib0.cpp:5
const TList * GetStreamerInfoCache()
Returns the cached list of StreamerInfos used in this file.
Definition: TFile.cxx:1298
Mother of all ROOT objects.
Definition: TObject.h:58
Bool_t FlushWriteCache()
Flush the write cache if active.
Definition: TFile.cxx:1097
static Bool_t SetOnlyStaged(Bool_t onlystaged)
Sets only staged flag.
Definition: TFile.cxx:4489
virtual void Paint(Option_t *option="")
Paint all objects in the file.
Definition: TFile.cxx:1524
virtual void SetCompressionSettings(Int_t settings=1)
Used to specify the compression level and algorithm.
Definition: TFile.cxx:2150
#define R__EXTERN
Definition: DllImport.h:27
char Char_t
Definition: RtypesCore.h:29
static TString fgCacheFileDir
Directory where to locally stage files.
Definition: TFile.h:104
virtual ~TFile()
File destructor.
Definition: TFile.cxx:542
static TFileOpenHandle * AsyncOpen(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Submit an asynchronous open request.
Definition: TFile.cxx:4091
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition: TFile.cxx:4371
Int_t MakeProjectParProofInf(const char *packname, const char *proofinfdir)
Create BUILD.sh and SETUP.C under 'proofinf' for PAR package 'pack'.
Definition: TFile.cxx:3265
virtual UShort_t WriteProcessID(TProcessID *pid)
Check if the ProcessID pidd is already in the file, if not, add it and return the index number in the...
Definition: TFile.cxx:3532
Int_t GetVersion() const
Definition: TFile.h:205
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
Definition: TFile.cxx:1647
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition: TFile.h:75
static UInt_t SetOpenTimeout(UInt_t timeout)
Sets open timeout time (in ms). Returns previous timeout value.
Definition: TFile.cxx:4469
virtual void SetCompressionAlgorithm(Int_t algorithm=0)
See comments for function SetCompressionSettings.
Definition: TFile.cxx:2116
Int_t fVersion
File format version.
Definition: TFile.h:70
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition: TFile.h:88
Int_t fCompress
Compression level and algorithm.
Definition: TFile.h:326
Int_t fWritten
Number of objects written so far.
Definition: TFile.h:74
static Int_t fgReadaheadSize
Readahead buffer size.
Definition: TFile.h:114
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:83
virtual void WriteHeader()
Write File Header.
Definition: TFile.cxx:2396
Bool_t fInitDone
!True if the file has been initialized
Definition: TFile.h:92
TFileOpenHandle * fAsyncHandle
!For proper automatic cleanup
Definition: TFile.h:95
EOpenTimeOut
Open timeout constants.
Definition: TFile.h:54
Long64_t GetArchiveOffset() const
Definition: TFile.h:181
static void SetFileBytesRead(Long64_t bytes=0)
Definition: TFile.cxx:4353
const Bool_t kTRUE
Definition: Rtypes.h:91
TObjArray * GetListOfProcessIDs() const
Definition: TFile.h:196
TObject * obj
Long64_t fSeekFree
Location on disk of free segments structure.
Definition: TFile.h:67
static Long64_t GetFileCounter()
Definition: TFile.cxx:4362
const Int_t n
Definition: legend1.C:16
virtual void SetCacheWrite(TFileCacheWrite *cache)
Set a pointer to the write cache.
Definition: TFile.cxx:2200
virtual void ResetErrno() const
Method resetting the errno. Is overridden in TRFIOFile.
Definition: TFile.cxx:1188
TFileCacheWrite * GetCacheWrite() const
Return a pointer to the current write cache.
Definition: TFile.cxx:1213
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:63
const char * GetOpt() const
Definition: TFile.h:345
static const char * GetCacheFileDir()
Get the directory where to locally stage/cache remote files.
Definition: TFile.cxx:4399
virtual Long64_t GetBytesReadExtra() const
Definition: TFile.h:202
virtual TProcessID * ReadProcessID(UShort_t pidf)
The TProcessID with number pidf is read from this file.
Definition: TFile.cxx:1777
TArrayC * GetClassIndex() const
Definition: TFile.h:186
A cache when writing files over the network.
Int_t GetNetOpt() const
Definition: TFile.h:347
Int_t MakeProjectParMake(const char *packname, const char *filename)
Create makefile at 'filemake' for PAR package 'pack'.
Definition: TFile.cxx:3143
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TFile.cxx:4955
TFileCacheWrite * fCacheWrite
!Pointer to the write cache (if any)
Definition: TFile.h:87
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:898
virtual Bool_t Matches(const char *name)
Return kTRUE if 'url' matches the coordinates of this file.
Definition: TFile.cxx:4511
Array of chars or bytes (8 bits per element).
Definition: TArrayC.h:29
ECacheAction
TTreeCache flushing semantics.
Definition: TFile.h:57
#define gFile
Definition: TFile.h:307
Stopwatch class.
Definition: TStopwatch.h:30
virtual EAsyncOpenStatus GetAsyncOpenStatus()
Definition: TFile.h:116