ROOT logo
// @(#)root/gfal:$Id$
// Author: Fons Rademakers   8/12/2005

/*************************************************************************
 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGFALFile
#define ROOT_TGFALFile


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGFALFile                                                            //
//                                                                      //
// A TGFALFile is like a normal TFile except that it reads and writes   //
// its data via the underlaying Grid access mechanism.                  //
// TGFALFile file names are either a logical file name, a guid, an      //
// SURL or a TURL, like:                                                //
//                                                                      //
//    gfal:/lfn/user/r/rdm/galice.root                                  //
//                                                                      //
// Grid storage interactions today require using several existing       //
// software components:                                                 //
//  - The replica catalog services to locate valid replicas of          //
//    files.                                                            //
//  - The SRM software to ensure:                                       //
//     - files  exist on disk (they are recalled from mass              //
//       storage if necessary) or                                       //
//     - space is allocated on disk for new files (they are possibly    //
//       migrated to mass storage later)                                //
//  - A file access mechanism to access files from the storage          //
//    system on the worker node.                                        //
//                                                                      //
// The GFAL library hides these interactions and presents a Posix       //
// interface for the I/O operations. The currently supported protocols  //
// are: file for local access, dcap, gsidcap and kdcap (dCache access   //
// protocol) and rfio (CASTOR access protocol).                         //
//                                                                      //
// File naming convention:                                              //
// A file name can be a Logical File Name (LFN), a Grid Unique          //
// IDentifier (GUID), a file replica (SURL) or a Transport file         //
// name (TURL):                                                         //
//                                                                      //
//     an LFN starts with lfn:                                          //
//        for example lfn:baud/testgfal15                               //
//                                                                      //
//     a GUID starts with guid:                                         //
//        for example guid:2cd59291-7ae7-4778-af6d-b1f423719441         //
//                                                                      //
//     an SURL starts with srm://                                       //
//         for example srm://wacdr002d.cern.ch:8443/castor/             //
//                    cern.ch/user/b/baud/testgfal15                    //
//                                                                      //
//      a TURL starts with a protocol name:                             //
//          for example rfio:////castor/cern.ch/user/b/baud/testgfal15  //
//                                                                      //
// Note that for the TGFALFile plugin to work, all these pathnames      //
// should be prepended by gfal:.                                        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TFile
#include "TFile.h"
#endif
#ifndef ROOT_TSystem
#include "TSystem.h"
#endif


class TGFALFile : public TFile {

private:
   Bool_t        fStatCached;  //! (transient) is file status cached?
   struct stat64 fStatBuffer;  //! (transient) Cached file status buffer (for performance)

   TGFALFile() : fStatCached(kFALSE) { }

   // Interface to basic system I/O routines
   Int_t    SysOpen(const char *pathname, Int_t flags, UInt_t mode);
   Int_t    SysClose(Int_t fd);
   Int_t    SysRead(Int_t fd, void *buf, Int_t len);
   Int_t    SysWrite(Int_t fd, const void *buf, Int_t len);
   Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
   Int_t    SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
   Int_t    SysSync(Int_t) { /* no fsync for GFAL */ return 0; }

public:
   TGFALFile(const char *url, Option_t *option="",
             const char *ftitle="", Int_t compress=1);
   ~TGFALFile();

   Bool_t  ReadBuffer(char *buf, Int_t len);
   Bool_t  ReadBuffer(char *buf, Long64_t pos, Int_t len);
   Bool_t  WriteBuffer(const char *buf, Int_t len);

   ClassDef(TGFALFile,1)  //A ROOT file that reads/writes via a GFAL
};


class TGFALSystem : public TSystem {

private:
   void    *fDirp;   // directory handler

   void    *GetDirPtr() const { return fDirp; }

public:
   TGFALSystem();
   virtual ~TGFALSystem() { }

   Int_t       MakeDirectory(const char *name);
   void       *OpenDirectory(const char *name);
   void        FreeDirectory(void *dirp);
   const char *GetDirEntry(void *dirp);
   Int_t       GetPathInfo(const char *path, FileStat_t &buf);
   Bool_t      AccessPathName(const char *path, EAccessMode mode);

   ClassDef(TGFALSystem,0)  // Directory handler for GFAL
};

#endif
 TGFALFile.h:1
 TGFALFile.h:2
 TGFALFile.h:3
 TGFALFile.h:4
 TGFALFile.h:5
 TGFALFile.h:6
 TGFALFile.h:7
 TGFALFile.h:8
 TGFALFile.h:9
 TGFALFile.h:10
 TGFALFile.h:11
 TGFALFile.h:12
 TGFALFile.h:13
 TGFALFile.h:14
 TGFALFile.h:15
 TGFALFile.h:16
 TGFALFile.h:17
 TGFALFile.h:18
 TGFALFile.h:19
 TGFALFile.h:20
 TGFALFile.h:21
 TGFALFile.h:22
 TGFALFile.h:23
 TGFALFile.h:24
 TGFALFile.h:25
 TGFALFile.h:26
 TGFALFile.h:27
 TGFALFile.h:28
 TGFALFile.h:29
 TGFALFile.h:30
 TGFALFile.h:31
 TGFALFile.h:32
 TGFALFile.h:33
 TGFALFile.h:34
 TGFALFile.h:35
 TGFALFile.h:36
 TGFALFile.h:37
 TGFALFile.h:38
 TGFALFile.h:39
 TGFALFile.h:40
 TGFALFile.h:41
 TGFALFile.h:42
 TGFALFile.h:43
 TGFALFile.h:44
 TGFALFile.h:45
 TGFALFile.h:46
 TGFALFile.h:47
 TGFALFile.h:48
 TGFALFile.h:49
 TGFALFile.h:50
 TGFALFile.h:51
 TGFALFile.h:52
 TGFALFile.h:53
 TGFALFile.h:54
 TGFALFile.h:55
 TGFALFile.h:56
 TGFALFile.h:57
 TGFALFile.h:58
 TGFALFile.h:59
 TGFALFile.h:60
 TGFALFile.h:61
 TGFALFile.h:62
 TGFALFile.h:63
 TGFALFile.h:64
 TGFALFile.h:65
 TGFALFile.h:66
 TGFALFile.h:67
 TGFALFile.h:68
 TGFALFile.h:69
 TGFALFile.h:70
 TGFALFile.h:71
 TGFALFile.h:72
 TGFALFile.h:73
 TGFALFile.h:74
 TGFALFile.h:75
 TGFALFile.h:76
 TGFALFile.h:77
 TGFALFile.h:78
 TGFALFile.h:79
 TGFALFile.h:80
 TGFALFile.h:81
 TGFALFile.h:82
 TGFALFile.h:83
 TGFALFile.h:84
 TGFALFile.h:85
 TGFALFile.h:86
 TGFALFile.h:87
 TGFALFile.h:88
 TGFALFile.h:89
 TGFALFile.h:90
 TGFALFile.h:91
 TGFALFile.h:92
 TGFALFile.h:93
 TGFALFile.h:94
 TGFALFile.h:95
 TGFALFile.h:96
 TGFALFile.h:97
 TGFALFile.h:98
 TGFALFile.h:99
 TGFALFile.h:100
 TGFALFile.h:101
 TGFALFile.h:102
 TGFALFile.h:103
 TGFALFile.h:104
 TGFALFile.h:105
 TGFALFile.h:106
 TGFALFile.h:107
 TGFALFile.h:108
 TGFALFile.h:109
 TGFALFile.h:110
 TGFALFile.h:111
 TGFALFile.h:112
 TGFALFile.h:113
 TGFALFile.h:114
 TGFALFile.h:115
 TGFALFile.h:116
 TGFALFile.h:117
 TGFALFile.h:118
 TGFALFile.h:119
 TGFALFile.h:120
 TGFALFile.h:121
 TGFALFile.h:122
 TGFALFile.h:123
 TGFALFile.h:124
 TGFALFile.h:125
 TGFALFile.h:126