#ifndef ROOT_TFile
#define ROOT_TFile
#ifndef ROOT_TDirectoryFile
#include "TDirectoryFile.h"
#endif
#ifndef ROOT_TUrl
#include "TUrl.h"
#endif
class TFree;
class TArrayC;
class TArchiveFile;
class TFileOpenHandle;
class TFileCacheRead;
class TFileCacheWrite;
class TProcessID;
class TStopwatch;
class TFile : public TDirectoryFile {
friend class TDirectoryFile;
public:
enum EAsyncOpenStatus { kAOSNotAsync = -1, kAOSFailure = 0,
kAOSInProgress = 1, kAOSSuccess = 2 };
enum EOpenTimeOut { kInstantTimeout = 0, kEternalTimeout = 999999999 };
protected:
Double_t fSumBuffer;
Double_t fSum2Buffer;
Long64_t fBytesWrite;
Long64_t fBytesRead;
Long64_t fBytesReadExtra;
Long64_t fBEGIN;
Long64_t fEND;
Long64_t fSeekFree;
Long64_t fSeekInfo;
Int_t fD;
Int_t fVersion;
Int_t fCompress;
Int_t fNbytesFree;
Int_t fNbytesInfo;
Int_t fWritten;
Int_t fNProcessIDs;
Int_t fReadCalls;
TString fRealName;
TString fOption;
Char_t fUnits;
TList *fFree;
TArrayC *fClassIndex;
TObjArray *fProcessIDs;
Long64_t fOffset;
TArchiveFile *fArchive;
TFileCacheRead *fCacheRead;
TFileCacheWrite *fCacheWrite;
Long64_t fArchiveOffset;
Bool_t fIsArchive;
Bool_t fNoAnchorInName;
Bool_t fIsRootFile;
Bool_t fInitDone;
Bool_t fMustFlush;
TFileOpenHandle *fAsyncHandle;
EAsyncOpenStatus fAsyncOpenStatus;
TUrl fUrl;
TList *fInfoCache;
TList *fOpenPhases;
static TList *fgAsyncOpenRequests;
static TString fgCacheFileDir;
static Bool_t fgCacheFileDisconnected;
static Bool_t fgCacheFileForce;
static UInt_t fgOpenTimeout;
static Bool_t fgOnlyStaged ;
static Long64_t fgBytesWrite;
static Long64_t fgBytesRead;
static Long64_t fgFileCounter;
static Int_t fgReadCalls;
static Int_t fgReadaheadSize;
static Bool_t fgReadInfo;
virtual EAsyncOpenStatus GetAsyncOpenStatus() { return fAsyncOpenStatus; }
virtual void Init(Bool_t create);
Bool_t FlushWriteCache();
Int_t ReadBufferViaCache(char *buf, Int_t len);
Int_t WriteBufferViaCache(const char *buf, Int_t len);
virtual Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
virtual Int_t SysClose(Int_t fd);
virtual Int_t SysRead(Int_t fd, void *buf, Int_t len);
virtual Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
virtual Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
virtual Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
virtual Int_t SysSync(Int_t fd);
virtual Long64_t DirCreateEntry(TDirectory*) { return 0; }
virtual Int_t DirReadKeys(TDirectory*) { return 0; }
virtual void DirWriteKeys(TDirectory*) {}
virtual void DirWriteHeader(TDirectory*) {}
private:
TFile(const TFile &);
void operator=(const TFile &);
static void CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch);
static TFile *OpenFromCache(const char *name, Option_t * = "",
const char *ftitle = "", Int_t compress = 1,
Int_t netopt = 0);
public:
enum EStatusBits {
kRecovered = BIT(10),
kHasReferences = BIT(11),
kDevNull = BIT(12),
kWriteError = BIT(14),
kBinaryFile = BIT(15),
kRedirected = BIT(16)
};
enum ERelativeTo { kBeg = 0, kCur = 1, kEnd = 2 };
enum { kStartBigFile = 2000000000 };
enum EFileType { kDefault = 0, kLocal = 1, kNet = 2, kWeb = 3, kFile = 4};
TFile();
TFile(const char *fname, Option_t *option="", const char *ftitle="", Int_t compress=1);
virtual ~TFile();
virtual void Close(Option_t *option="");
virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize);
virtual TKey* CreateKey(TDirectory* mother, const void* obj, const TClass* cl,
const char* name, Int_t bufsize);
virtual void Delete(const char *namecycle="");
virtual void Draw(Option_t *option="");
virtual void DrawMap(const char *keys="*",Option_t *option="");
virtual void FillBuffer(char *&buffer);
virtual void Flush();
TArchiveFile *GetArchive() const { return fArchive; }
Int_t GetBestBuffer() const;
virtual Int_t GetBytesToPrefetch() const;
TFileCacheRead *GetCacheRead() const;
TFileCacheWrite *GetCacheWrite() const;
TArrayC *GetClassIndex() const { return fClassIndex; }
Int_t GetCompressionLevel() const { return fCompress; }
Float_t GetCompressionFactor();
virtual Long64_t GetEND() const { return fEND; }
virtual Int_t GetErrno() const;
virtual void ResetErrno() const;
Int_t GetFd() const { return fD; }
virtual const TUrl *GetEndpointUrl() const { return &fUrl; }
TObjArray *GetListOfProcessIDs() const {return fProcessIDs;}
TList *GetListOfFree() const { return fFree; }
virtual Int_t GetNfree() const { return fFree->GetSize(); }
virtual Int_t GetNProcessIDs() const { return fNProcessIDs; }
Option_t *GetOption() const { return fOption.Data(); }
virtual Long64_t GetBytesRead() const { return fBytesRead; }
virtual Long64_t GetBytesReadExtra() const { return fBytesReadExtra; }
virtual Long64_t GetBytesWritten() const;
virtual Int_t GetReadCalls() const { return fReadCalls; }
Int_t GetVersion() const { return fVersion; }
Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes,
Int_t &nbytes, Int_t &objlen, Int_t &keylen);
virtual Int_t GetNbytesInfo() const {return fNbytesInfo;}
virtual Int_t GetNbytesFree() const {return fNbytesFree;}
Long64_t GetRelOffset() const { return fOffset - fArchiveOffset; }
virtual Long64_t GetSeekFree() const {return fSeekFree;}
virtual Long64_t GetSeekInfo() const {return fSeekInfo;}
virtual Long64_t GetSize() const;
virtual TList *GetStreamerInfoList();
const TList *GetStreamerInfoCache();
virtual void IncrementProcessIDs() { fNProcessIDs++; }
virtual Bool_t IsArchive() const { return fIsArchive; }
Bool_t IsBinary() const { return TestBit(kBinaryFile); }
Bool_t IsRaw() const { return !fIsRootFile; }
virtual Bool_t IsOpen() const;
virtual void ls(Option_t *option="") const;
virtual void MakeFree(Long64_t first, Long64_t last);
virtual void MakeProject(const char *dirname, const char *classes="*",
Option_t *option="new");
virtual void Map();
virtual Bool_t Matches(const char *name);
virtual Bool_t MustFlush() const {return fMustFlush;}
virtual void Paint(Option_t *option="");
virtual void Print(Option_t *option="") const;
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
virtual Bool_t ReadBuffer(char *buf, Int_t len);
virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
virtual void ReadFree();
virtual TProcessID *ReadProcessID(UShort_t pidf);
virtual void ReadStreamerInfo();
virtual Int_t Recover();
virtual Int_t ReOpen(Option_t *mode);
virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
virtual void SetCacheRead(TFileCacheRead *cache);
virtual void SetCacheWrite(TFileCacheWrite *cache);
virtual void SetCompressionLevel(Int_t level=1);
virtual void SetEND(Long64_t last) { fEND = last; }
virtual void SetOffset(Long64_t offset, ERelativeTo pos = kBeg);
virtual void SetOption(Option_t *option=">") { fOption = option; }
virtual void SetReadCalls(Int_t readcalls = 0) { fReadCalls = readcalls; }
virtual void ShowStreamerInfo();
virtual Int_t Sizeof() const;
void SumBuffer(Int_t bufsize);
virtual void UseCache(Int_t maxCacheSize = 10, Int_t pageSize = 0);
virtual Bool_t WriteBuffer(const char *buf, Int_t len);
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 void WriteFree();
virtual void WriteHeader();
virtual UShort_t WriteProcessID(TProcessID *pid);
virtual void WriteStreamerInfo();
static TFileOpenHandle
*AsyncOpen(const char *name, Option_t *option = "",
const char *ftitle = "", Int_t compress = 1,
Int_t netopt = 0);
static TFile *Open(const char *name, Option_t *option = "",
const char *ftitle = "", Int_t compress = 1,
Int_t netopt = 0);
static TFile *Open(TFileOpenHandle *handle);
static EFileType GetType(const char *name, Option_t *option = "", TString *prefix = 0);
static EAsyncOpenStatus GetAsyncOpenStatus(const char *name);
static EAsyncOpenStatus GetAsyncOpenStatus(TFileOpenHandle *handle);
static const TUrl *GetEndpointUrl(const char *name);
static Long64_t GetFileBytesRead();
static Long64_t GetFileBytesWritten();
static Int_t GetFileReadCalls();
static Int_t GetReadaheadSize();
static void SetFileBytesRead(Long64_t bytes = 0);
static void SetFileBytesWritten(Long64_t bytes = 0);
static void SetFileReadCalls(Int_t readcalls = 0);
static void SetReadaheadSize(Int_t bufsize = 256000);
static void SetReadStreamerInfo(Bool_t readinfo=kTRUE);
static Long64_t GetFileCounter();
static void IncrementFileCounter();
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected = kTRUE,
Bool_t forceCacheread = kFALSE);
static const char *GetCacheFileDir();
static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval = 0);
static Bool_t Cp(const char *src, const char *dst, Bool_t progressbar = kTRUE,
UInt_t buffersize = 1000000);
static UInt_t SetOpenTimeout(UInt_t timeout);
static UInt_t GetOpenTimeout();
static Bool_t SetOnlyStaged(Bool_t onlystaged);
static Bool_t GetOnlyStaged();
ClassDef(TFile,8)
};
class TFileOpenHandle : public TNamed {
friend class TFile;
friend class TAlienFile;
private:
TString fOpt;
Int_t fCompress;
Int_t fNetOpt;
TFile *fFile;
TFileOpenHandle(TFile *f) : TNamed("",""), fOpt(""), fCompress(1),
fNetOpt(0), fFile(f) { }
TFileOpenHandle(const char *n, const char *o, const char *t, Int_t cmp,
Int_t no) : TNamed(n,t), fOpt(o), fCompress(cmp),
fNetOpt(no), fFile(0) { }
TFileOpenHandle(const TFileOpenHandle&);
TFileOpenHandle& operator=(const TFileOpenHandle&);
TFile *GetFile() const { return fFile; }
public:
~TFileOpenHandle() { }
Bool_t Matches(const char *name);
const char *GetOpt() const { return fOpt; }
Int_t GetCompress() const { return fCompress; }
Int_t GetNetOpt() const { return fNetOpt; }
};
R__EXTERN TFile *gFile;
#endif