Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TDCacheFile.h
Go to the documentation of this file.
1 // @(#)root/dcache:$Id$
2 // Author: Grzegorz Mazur 20/01/2002
3 // Updated: William Tanenbaum 21/11/2003
4 // Updated: Tgiran Mkrtchyan 28/06/2004
5 
6 /*************************************************************************
7  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
8  * All rights reserved. *
9  * *
10  * For the licensing terms see $ROOTSYS/LICENSE. *
11  * For the list of contributors see $ROOTSYS/README/CREDITS. *
12  *************************************************************************/
13 
14 #ifndef ROOT_TDCacheFile
15 #define ROOT_TDCacheFile
16 
17 #include "TFile.h"
18 #include "TSystem.h"
19 #include "TString.h"
20 
21 #include <sys/stat.h>
22 
23 #define RAHEAD_BUFFER_SIZE 131072
24 
25 class TDCacheFile : public TFile {
26 
27 private:
28  Bool_t fStatCached; ///<! (transient) is file status cached?
29  struct stat64 fStatBuffer; ///<! (transient) Cached file status buffer (for performance)
30 
31  TDCacheFile() : fStatCached(kFALSE) { }
32 
33  // Interface to basic system I/O routines
34  Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
35  Int_t SysClose(Int_t fd);
36  Int_t SysRead(Int_t fd, void *buf, Int_t len);
37  Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
38  Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
39  Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
40  Int_t SysSync(Int_t fd);
41 
42 public:
43  TDCacheFile(const char *path, Option_t *option="",
44  const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
45 
46  ~TDCacheFile();
47 
48  Bool_t ReadBuffer(char *buf, Int_t len);
49  Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
50  Bool_t WriteBuffer(const char *buf, Int_t len);
51 
52  Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
53 
54  void ResetErrno() const;
55 
56  static Bool_t Stage(const char *path, UInt_t secs,
57  const char *location = 0);
58  static Bool_t CheckFile(const char *path, const char *location = 0);
59 
60  /// Note: This must be kept in sync with values \#defined in dcap.h
61  enum EOnErrorAction {
62  kOnErrorRetry = 1,
63  kOnErrorFail = 0,
64  kOnErrorDefault = -1
65  };
66 
67  static void SetOpenTimeout(UInt_t secs);
68  static void SetOnError(EOnErrorAction = kOnErrorDefault);
69 
70  static void SetReplyHostName(const char *host_name);
71  static const char *GetDcapVersion();
72  static TString GetDcapPath(const char *path);
73 
74 
75  ClassDef(TDCacheFile,1) //A ROOT file that reads/writes via a dCache server
76 };
77 
78 
79 class TDCacheSystem : public TSystem {
80 
81 private:
82  void *fDirp; ///< directory handler
83 
84  void *GetDirPtr() const { return fDirp; }
85 
86 public:
87  TDCacheSystem();
88  virtual ~TDCacheSystem() { }
89 
90  Int_t MakeDirectory(const char *name);
91  void *OpenDirectory(const char *name);
92  void FreeDirectory(void *dirp);
93  const char *GetDirEntry(void *dirp);
94  Int_t GetPathInfo(const char *path, FileStat_t &buf);
95  Bool_t AccessPathName(const char *path, EAccessMode mode);
96 
97  ClassDef(TDCacheSystem,0) // Directory handler for DCache
98 };
99 
100 #endif