00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ROOT_TDCacheFile
00015 #define ROOT_TDCacheFile
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROOT_TFile
00029 #include "TFile.h"
00030 #endif
00031 #ifndef ROOT_TSystem
00032 #include "TSystem.h"
00033 #endif
00034 #ifndef ROOT_TString
00035 #include "TString.h"
00036 #endif
00037
00038 #include <sys/stat.h>
00039
00040 #define RAHEAD_BUFFER_SIZE 131072
00041
00042 class TDCacheFile : public TFile {
00043
00044 private:
00045 Bool_t fStatCached;
00046 struct stat64 fStatBuffer;
00047
00048 TDCacheFile() : fStatCached(kFALSE) { }
00049
00050
00051 Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
00052 Int_t SysClose(Int_t fd);
00053 Int_t SysRead(Int_t fd, void *buf, Int_t len);
00054 Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
00055 Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
00056 Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
00057 Int_t SysSync(Int_t fd);
00058
00059 public:
00060 TDCacheFile(const char *path, Option_t *option="",
00061 const char *ftitle="", Int_t compress=1);
00062
00063 ~TDCacheFile();
00064
00065 Bool_t ReadBuffer(char *buf, Int_t len);
00066 Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
00067 Bool_t WriteBuffer(const char *buf, Int_t len);
00068
00069 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
00070
00071 void ResetErrno() const;
00072
00073 static Bool_t Stage(const char *path, UInt_t secs,
00074 const char *location = 0);
00075 static Bool_t CheckFile(const char *path, const char *location = 0);
00076
00077
00078 enum OnErrorAction {
00079 kOnErrorRetry = 1,
00080 kOnErrorFail = 0,
00081 kOnErrorDefault = -1
00082 };
00083
00084 static void SetOpenTimeout(UInt_t secs);
00085 static void SetOnError(OnErrorAction = kOnErrorDefault);
00086
00087 static void SetReplyHostName(const char *host_name);
00088 static const char *GetDcapVersion();
00089 static TString GetDcapPath(const char *path);
00090
00091
00092 ClassDef(TDCacheFile,1)
00093 };
00094
00095
00096 class TDCacheSystem : public TSystem {
00097
00098 private:
00099 void *fDirp;
00100
00101 void *GetDirPtr() const { return fDirp; }
00102
00103 public:
00104 TDCacheSystem();
00105 virtual ~TDCacheSystem() { }
00106
00107 Int_t MakeDirectory(const char *name);
00108 void *OpenDirectory(const char *name);
00109 void FreeDirectory(void *dirp);
00110 const char *GetDirEntry(void *dirp);
00111 Int_t GetPathInfo(const char *path, FileStat_t &buf);
00112 Bool_t AccessPathName(const char *path, EAccessMode mode);
00113
00114 ClassDef(TDCacheSystem,0)
00115 };
00116
00117 #endif