library: libDCache #include "TDCacheFile.h"

# TDCacheFile

class description - source file - inheritance tree (.pdf)

## class TDCacheFile : public TFile

| Inheritance Chart:
`TObject`
| <- | `TNamed`
| <- | `TDirectory`
| <- | `TFile`
| <- | `TDCacheFile` |

        private:

                           TDCacheFile()
             virtual Int_t SysClose(Int_t fd)
             virtual Int_t SysOpen(const char* pathname, Int_t flags, UInt_t mode)
             virtual Int_t SysRead(Int_t fd, 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 Int_t SysWrite(Int_t fd, const void* buf, Int_t len)

        public:

                             TDCacheFile(const char* path, Option_t* option = "", const char* ftitle = "", Int_t compress = 1)
                             ~TDCacheFile()
               static Bool_t CheckFile(const char* path, const char* location = "0")
              static TClass* Class()
              static TString GetDcapPath(const char* path)
          static const char* GetDcapVersion() const
             virtual TClass* IsA() const
              virtual Bool_t ReadBuffer(char* buf, Int_t len)
                virtual void ResetErrno() const
                 static void SetOnError(TDCacheFile::OnErrorAction = kOnErrorDefault)
                 static void SetOpenTimeout(UInt_t secs)
                 static void SetReplyHostName(const char* host_name)
                virtual void ShowMembers(TMemberInspector& insp, char* parent)
               static Bool_t Stage(const char* path, UInt_t secs, const char* location = "0")
                virtual void Streamer(TBuffer& b)
                        void StreamerNVirtual(TBuffer& b)
              virtual Bool_t WriteBuffer(const char* buf, Int_t len)

### Data Members

        private:

                       Bool_t fStatCached  ! (transient) is file status cached?
          TDCacheFile::stat64 fStatBuffer  ! (transient) Cached file status buffer (for performance)

        public:

          static const TDCacheFile::OnErrorAction kOnErrorRetry
          static const TDCacheFile::OnErrorAction kOnErrorFail
          static const TDCacheFile::OnErrorAction kOnErrorDefault

## Class Description

     TDCacheFile

     A TDCacheFile is like a normal TFile except that it may read and
     write its data via a dCache server (for more on the dCache daemon
     see http://www-dcache.desy.de/. Given a path which doesn't belong
     to the dCache managed filesystem, it falls back to the ordinary
     TFile behaviour.

TDCacheFile(const char *path, Option_t *option, const char *ftitle, Int_t compress): TFile(path, "NET", ftitle, compress)

     Create a dCache file object. A dCache file is the same as a TFile
     except that it is being accessed via a dCache server. The url
     argument must be of the form: dcache://path/file.root or
     dcap://path/file.root. If the file specified in the URL does not
     exist, is not accessable or can not be created the kZombie bit will
     be set in the TDCacheFile object. Use IsZombie() to see if the file
     is accessable. For a description of the option and other arguments
     see the TFile ctor. The preferred interface to this constructor is
     via TFile::Open().

~TDCacheFile()

     Close and cleanup dCache file.

Bool_t ReadBuffer(char *buf, Int_t len)

     Read specified byte range from remote file via dCache daemon.
     Returns kTRUE in case of error.

Bool_t WriteBuffer(const char *buf, Int_t len)

     Write specified byte range to remote file via dCache daemon.
     Returns kTRUE in case of error.

Bool_t Stage(const char *path, UInt_t after, const char *location)

     Stage() returns kTRUE on success and kFALSE on failure.

Bool_t CheckFile(const char *path, const char *location)

     CheckFile() returns kTRUE on success and kFALSE on failure.  In
     case the file exists but is not cached, CheckFile() returns
     kFALSE and errno is set to EAGAIN.

void SetOpenTimeout(UInt_t n)

     Set file open timeout.

void SetOnError(OnErrorAction a)

     Set on error handler.

void SetReplyHostName(const char *host_name)

     Set reply host name.

const char* GetDcapVersion()

     Return dCache version string.

Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)

     Interface to system open. All arguments like in POSIX open.

Int_t SysClose(Int_t fd)

     Interface to system close. All arguments like in POSIX close.

Int_t SysRead(Int_t fd, void *buf, Int_t len)

     Interface to system read. All arguments like in POSIX read.

Int_t SysWrite(Int_t fd, const void *buf, Int_t len)

     Interface to system write. All arguments like in POSIX write.

Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)

     Interface to system seek. All arguments like in POSIX lseek.

Int_t SysSync(Int_t fd)

     Interface to system sync. All arguments like in POSIX fsync.
     dCache always keep it's files sync'ed, so there's no need to
     sync() them manually.

Int_t SysStat(Int_t, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)

     Get info about a file: id, size, flags, modification time.
     Id      is (statbuf.st_dev << 24) + statbuf.st_ino
     Size    is the file size
     Flags   is file type: 0 is regular file, bit 0 set executable,
                           bit 1 set directory, bit 2 set special file
                           (socket, fifo, pipe, etc.)
     Modtime is modification time.
     The function returns 0 in case of success and 1 if the file could
     not be stat'ed.

void ResetErrno() const

     Method resetting the dc_errno and errno.

TString GetDcapPath(const char *path)

     Transform the input path into a path usuable by the dcap C library,
     i.e either dcap://nodename.org/where/filename.root or
     //pnfs/where/filename.root

### Inline Functions

            TDCacheFile TDCacheFile(const char* path, Option_t* option = "", const char* ftitle = "", Int_t compress = 1)
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)

Author: Grzegorz Mazur 20/01/2002
Last update: root/dcache:$Name: $:$Id: TDCacheFile.cxx,v 1.24 2005/02/28 17:28:12 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *