TNetFile.h

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TNetFile.h 34444 2010-07-16 02:17:39Z pcanal $
00002 // Author: Fons Rademakers   14/08/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TNetFile
00013 #define ROOT_TNetFile
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TNetFile                                                             //
00019 //                                                                      //
00020 // A TNetFile is like a normal TFile except that it reads and writes    //
00021 // its data via a rootd server.                                         //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef ROOT_TFile
00026 #include "TFile.h"
00027 #endif
00028 #ifndef ROOT_TUrl
00029 #include "TUrl.h"
00030 #endif
00031 #ifndef ROOT_TFTP
00032 #include "TFTP.h"
00033 #endif
00034 #ifndef ROOT_TSystem
00035 #include "TSystem.h"
00036 #endif
00037 #ifndef ROOT_MessageTypes
00038 #include "MessageTypes.h"
00039 #endif
00040 
00041 class TSocket;
00042 
00043 
00044 class TNetFile : public TFile {
00045 
00046 protected:
00047    TUrl      fEndpointUrl; //URL of realfile (after possible redirection)
00048    TString   fUser;        //remote user name
00049    TSocket  *fSocket;      //connection to rootd server
00050    Int_t     fProtocol;    //rootd protocol level
00051    Int_t     fErrorCode;   //error code returned by rootd (matching gRootdErrStr)
00052    Int_t     fNetopt;      //initial network options (used for ReOpen())
00053 
00054    TNetFile(const TNetFile&);             // NetFile cannot be copied
00055    TNetFile& operator=(const TNetFile&);  // NetFile cannot be copied
00056 
00057    TNetFile(const char *url, const char *ftitle, Int_t comp, Bool_t);
00058    virtual void ConnectServer(Int_t *stat, EMessageTypes *kind, Int_t netopt,
00059                               Int_t tcpwindowsize, Bool_t forceOpen,
00060                               Bool_t forceRead);
00061    virtual void Create(const char *url, Option_t *option, Int_t netopt);
00062    virtual void Create(TSocket *s, Option_t *option, Int_t netopt);
00063    void         Init(Bool_t create);
00064    void         Print(Option_t *option) const;
00065    void         PrintError(const char *where, Int_t err);
00066    Int_t        Recv(Int_t &status, EMessageTypes &kind);
00067    Int_t        SysOpen(const char *pathname, Int_t flags, UInt_t mode);
00068    Int_t        SysClose(Int_t fd);
00069    Int_t        SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
00070 
00071 public:
00072    TNetFile(const char *url, Option_t *option = "", const char *ftitle = "",
00073             Int_t compress = 1, Int_t netopt = 0);
00074    TNetFile() : fEndpointUrl(), fUser(), fSocket(0), fProtocol(0), fErrorCode(0), fNetopt(0) { }
00075    virtual ~TNetFile();
00076 
00077    void    Close(Option_t *option="");  // *MENU*
00078    void    Flush();
00079    Int_t   GetErrorCode() const { return fErrorCode; }
00080    Bool_t  IsOpen() const;
00081    Bool_t  Matches(const char *url);
00082    Int_t   ReOpen(Option_t *mode);
00083    Bool_t  ReadBuffer(char *buf, Int_t len);
00084    Bool_t  ReadBuffer(char *buf, Long64_t pos, Int_t len);
00085    Bool_t  ReadBuffers(char *buf,  Long64_t *pos, Int_t *len, Int_t nbuf);
00086    Bool_t  WriteBuffer(const char *buf, Int_t len);
00087    void    Seek(Long64_t offset, ERelativeTo pos = kBeg);
00088 
00089    const TUrl *GetEndpointUrl() const { return &fEndpointUrl; }
00090 
00091    ClassDef(TNetFile,1)  //A ROOT file that reads/writes via a rootd server
00092 };
00093 
00094 
00095 class TNetSystem : public TSystem {
00096 
00097 private:
00098    Bool_t      fDir;         // true if a directory is open remotely
00099    void       *fDirp;        // directory handler
00100    TFTP       *fFTP;         // Connection to rootd
00101    TString     fHost;        // Remote host
00102    Bool_t      fFTPOwner;    // True if owner of the FTP instance
00103    TString     fUser;        // Remote user
00104    Int_t       fPort;        // Remote port
00105 
00106    TNetSystem(const TNetSystem&);             // not implemented
00107    TNetSystem& operator=(const TNetSystem&);  // not implemented
00108 
00109    void       *GetDirPtr() const { return fDirp; }
00110 
00111 protected:
00112    Bool_t      fIsLocal;     // TRUE if the path points to this host
00113    TString     fLocalPrefix; // if fIsLocal, prefix to be prepend locally
00114 
00115    void        Create(const char *url, TSocket *sock = 0);
00116    void        InitRemoteEntity(const char *url);
00117 
00118 public:
00119    TNetSystem(Bool_t ftpowner = kTRUE);
00120    TNetSystem(const char *url, Bool_t ftpowner = kTRUE);
00121    virtual ~TNetSystem();
00122 
00123    Bool_t      ConsistentWith(const char *path, void *dirptr);
00124    Int_t       MakeDirectory(const char *name);
00125    void       *OpenDirectory(const char *name);
00126    void        FreeDirectory(void *dirp = 0);
00127    const char *GetDirEntry(void *dirp = 0);
00128    Int_t       GetPathInfo(const char *path, FileStat_t &buf);
00129    Bool_t      AccessPathName(const char *path, EAccessMode mode);
00130    int         Unlink(const char *path);
00131 
00132    ClassDef(TNetSystem,0)  // Directory handler for NetSystem
00133 };
00134 
00135 #endif

Generated on Tue Jul 5 14:27:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1