Logo ROOT  
Reference Guide
No Matches
Go to the documentation of this file.
1// @(#)root/net:$Id$
2// Author: Fons Rademakers 14/08/97
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12#ifndef ROOT_TNetFile
13#define ROOT_TNetFile
17// //
18// TNetFile //
19// //
20// A TNetFile is like a normal TFile except that it reads and writes //
21// its data via a rootd server. //
22// //
25#include "TFile.h"
26#include "TUrl.h"
27#include "TFTP.h"
28#include "TSystem.h"
29#include "MessageTypes.h"
31class TSocket;
34class TNetFile : public TFile {
37 TUrl fEndpointUrl; //URL of realfile (after possible redirection)
38 TString fUser; //remote user name
39 TSocket *fSocket; //connection to rootd server
40 Int_t fProtocol; //rootd protocol level
41 Int_t fErrorCode; //error code returned by rootd (matching gRootdErrStr)
42 Int_t fNetopt; //initial network options (used for ReOpen())
44 TNetFile(const TNetFile&); // NetFile cannot be copied
45 TNetFile& operator=(const TNetFile&); // NetFile cannot be copied
47 TNetFile(const char *url, const char *ftitle, Int_t comp, Bool_t);
48 virtual void ConnectServer(Int_t *stat, EMessageTypes *kind, Int_t netopt,
49 Int_t tcpwindowsize, Bool_t forceOpen,
50 Bool_t forceRead);
51 virtual void Create(const char *url, Option_t *option, Int_t netopt);
52 virtual void Create(TSocket *s, Option_t *option, Int_t netopt);
53 void Init(Bool_t create);
54 void Print(Option_t *option) const;
55 void PrintError(const char *where, Int_t err);
56 Int_t Recv(Int_t &status, EMessageTypes &kind);
57 Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
59 Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
62 TNetFile(const char *url, Option_t *option = "", const char *ftitle = "",
65 virtual ~TNetFile();
67 void Close(Option_t *option=""); // *MENU*
68 void Flush();
69 Int_t GetErrorCode() const { return fErrorCode; }
70 Bool_t IsOpen() const;
71 Bool_t Matches(const char *url);
72 Int_t ReOpen(Option_t *mode);
73 Bool_t ReadBuffer(char *buf, Int_t len);
74 Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
75 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
76 Bool_t WriteBuffer(const char *buf, Int_t len);
77 void Seek(Long64_t offset, ERelativeTo pos = kBeg);
79 const TUrl *GetEndpointUrl() const { return &fEndpointUrl; }
81 ClassDef(TNetFile,1) //A ROOT file that reads/writes via a rootd server
85class TNetSystem : public TSystem {
88 Bool_t fDir; // true if a directory is open remotely
89 void *fDirp; // directory handler
90 TFTP *fFTP; // Connection to rootd
91 TString fHost; // Remote host
92 Bool_t fFTPOwner; // True if owner of the FTP instance
93 TString fUser; // Remote user
94 Int_t fPort; // Remote port
96 TNetSystem(const TNetSystem&); // not implemented
97 TNetSystem& operator=(const TNetSystem&); // not implemented
99 void *GetDirPtr() const { return fDirp; }
102 Bool_t fIsLocal; // TRUE if the path points to this host
103 TString fLocalPrefix; // if fIsLocal, prefix to be prepend locally
105 void Create(const char *url, TSocket *sock = 0);
106 void InitRemoteEntity(const char *url);
109 TNetSystem(Bool_t ftpowner = kTRUE);
110 TNetSystem(const char *url, Bool_t ftpowner = kTRUE);
111 virtual ~TNetSystem();
113 Bool_t ConsistentWith(const char *path, void *dirptr);
114 Int_t MakeDirectory(const char *name);
115 void *OpenDirectory(const char *name);
116 void FreeDirectory(void *dirp = 0);
117 const char *GetDirEntry(void *dirp = 0);
118 Int_t GetPathInfo(const char *path, FileStat_t &buf);
119 Bool_t AccessPathName(const char *path, EAccessMode mode);
120 int Unlink(const char *path);
122 ClassDef(TNetSystem,0) // Directory handler for NetSystem
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
long long Long64_t
Definition RtypesCore.h:80
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
Definition TSystem.h:43
Definition TFTP.h:34
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
Definition TFile.h:193
@ kBeg
Definition TFile.h:193
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Open a remote file. Requires fOption to be set correctly.
Definition TNetFile.cxx:113
Int_t GetErrorCode() const
Definition TNetFile.h:69
void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition TNetFile.cxx:566
void Print(Option_t *option) const
Print some info about the net file.
Definition TNetFile.cxx:259
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Return file stat information.
Definition TNetFile.cxx:160
virtual void Create(const char *url, Option_t *option, Int_t netopt)
Create a NetFile object.
Definition TNetFile.cxx:663
Int_t fProtocol
Definition TNetFile.h:40
TNetFile(const TNetFile &)
virtual void ConnectServer(Int_t *stat, EMessageTypes *kind, Int_t netopt, Int_t tcpwindowsize, Bool_t forceOpen, Bool_t forceRead)
Connect to remote rootd server.
Definition TNetFile.cxx:574
Int_t Recv(Int_t &status, EMessageTypes &kind)
Return status from rootd server and message kind.
Definition TNetFile.cxx:550
Bool_t IsOpen() const
Retruns kTRUE if file is open, kFALSE otherwise.
Definition TNetFile.cxx:251
Definition TNetFile.h:64
TUrl fEndpointUrl
Definition TNetFile.h:37
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read a list of buffers given in pos[] and len[] and return it in a single buffer.
Definition TNetFile.cxx:388
TString fUser
Definition TNetFile.h:38
Bool_t Matches(const char *url)
Return kTRUE if 'url' matches the coordinates of this file.
Definition TNetFile.cxx:765
Int_t SysClose(Int_t fd)
Close currently open file.
Definition TNetFile.cxx:148
void PrintError(const char *where, Int_t err)
Print error string depending on error code.
Definition TNetFile.cxx:274
const TUrl * GetEndpointUrl() const
Definition TNetFile.h:79
Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via rootd daemon.
Definition TNetFile.cxx:304
void Init(Bool_t create)
Initialize a TNetFile object.
Definition TNetFile.cxx:240
Bool_t WriteBuffer(const char *buf, Int_t len)
Write specified byte range to remote file via rootd daemon.
Definition TNetFile.cxx:492
Int_t fNetopt
Definition TNetFile.h:42
Int_t fErrorCode
Definition TNetFile.h:41
void Close(Option_t *option="")
Close remote file.
Definition TNetFile.cxx:212
virtual ~TNetFile()
TNetFile dtor. Send close message and close socket.
Definition TNetFile.cxx:105
void Flush()
Flush file to disk.
Definition TNetFile.cxx:229
TSocket * fSocket
Definition TNetFile.h:39
TNetFile & operator=(const TNetFile &)
Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode, like from READ to UPDATE or from NEW, CREATE,...
Definition TNetFile.cxx:289
const char * GetDirEntry(void *dirp=0)
Get directory entry via rootd. Returns 0 in case no more entries.
TString fLocalPrefix
Definition TNetFile.h:103
TString fHost
Definition TNetFile.h:91
TString fUser
Definition TNetFile.h:93
void InitRemoteEntity(const char *url)
Parse and save coordinates of the remote entity (user, host, port, ...)
Definition TNetFile.cxx:838
Int_t MakeDirectory(const char *name)
Make a directory via rootd.
Definition TNetFile.cxx:964
void Create(const char *url, TSocket *sock=0)
Create a TNetSystem object.
Definition TNetFile.cxx:862
void FreeDirectory(void *dirp=0)
Free directory via rootd.
Bool_t ConsistentWith(const char *path, void *dirptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
Bool_t fDir
Definition TNetFile.h:88
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
TNetSystem & operator=(const TNetSystem &)
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
virtual ~TNetSystem()
Definition TNetFile.cxx:940
void * fDirp
Definition TNetFile.h:89
void * GetDirPtr() const
Definition TNetFile.h:99
Bool_t fFTPOwner
Definition TNetFile.h:92
Definition TNetFile.h:90
TNetSystem(const TNetSystem &)
int Unlink(const char *path)
Remove a path.
void * OpenDirectory(const char *name)
Open a directory and return an opaque pointer to a dir structure.
Definition TNetFile.cxx:986
Int_t fPort
Definition TNetFile.h:94
Bool_t fIsLocal
Definition TNetFile.h:102
Basic string class.
Definition TString.h:136
Abstract base class defining a generic interface to the underlying Operating System.
Definition TSystem.h:266
This class represents a WWW compatible URL.
Definition TUrl.h:33
@ kUseCompiledDefault
Use the compile-time default setting.
Definition Compression.h:50