Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TNetFile.h
Go to the documentation of this file.
1// @(#)root/net:$Id$
2// Author: Fons Rademakers 14/08/97
3
4/*************************************************************************
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 *************************************************************************/
11
12#ifndef ROOT_TNetFile
13#define ROOT_TNetFile
14
15
16//////////////////////////////////////////////////////////////////////////
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// //
23//////////////////////////////////////////////////////////////////////////
24
25#include "TFile.h"
26#include "TUrl.h"
27#include "TFTP.h"
28#include "TSystem.h"
29#include "MessageTypes.h"
30
31class TSocket;
32
33namespace ROOT::Deprecated {
34
35class TNetFile : public TFile {
36
37protected:
38 TUrl fEndpointUrl; //URL of realfile (after possible redirection)
39 TString fUser; //remote user name
40 TSocket *fSocket; //connection to rootd server
41 Int_t fProtocol; //rootd protocol level
42 Int_t fErrorCode; //error code returned by rootd (matching gRootdErrStr)
43 Int_t fNetopt; //initial network options (used for ReOpen())
44
45 TNetFile(const TNetFile&); // NetFile cannot be copied
46 TNetFile& operator=(const TNetFile&); // NetFile cannot be copied
47
48 TNetFile(const char *url, const char *ftitle, Int_t comp, Bool_t);
49 virtual void ConnectServer(Int_t *stat, EMessageTypes *kind, Int_t netopt,
52 virtual void Create(const char *url, Option_t *option, Int_t netopt);
53 virtual void Create(TSocket *s, Option_t *option, Int_t netopt);
54 void Init(Bool_t create) override;
55 void Print(Option_t *option) const override;
56 void PrintError(const char *where, Int_t err);
57 Int_t Recv(Int_t &status, EMessageTypes &kind);
58 Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override;
59 Int_t SysClose(Int_t fd) override;
60 Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override;
61
62public:
63 TNetFile(const char *url, Option_t *option = "", const char *ftitle = "",
65 TNetFile() : fEndpointUrl(), fUser(), fSocket(nullptr), fProtocol(0), fErrorCode(0), fNetopt(0) { }
66 virtual ~TNetFile();
67
68 void Close(Option_t *option="") override; // *MENU*
69 void Flush() override;
70 Int_t GetErrorCode() const { return fErrorCode; }
71 Bool_t IsOpen() const override;
72 Bool_t Matches(const char *url) override;
73 Int_t ReOpen(Option_t *mode) override;
74 Bool_t ReadBuffer(char *buf, Int_t len) override;
75 Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override;
76 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override;
77 Bool_t WriteBuffer(const char *buf, Int_t len) override;
78 void Seek(Long64_t offset, ERelativeTo pos = kBeg) override;
79
80 const TUrl *GetEndpointUrl() const override { return &fEndpointUrl; }
81
82 ClassDefOverride(TNetFile,1) //A ROOT file that reads/writes via a rootd server
83};
84
85class TNetSystem : public TSystem {
86
87private:
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
95
96 TNetSystem(const TNetSystem&) = delete;
97 TNetSystem& operator=(const TNetSystem&) = delete;
98
99 void *GetDirPtr() const override { return fDirp; }
100
101protected:
102 Bool_t fIsLocal; // TRUE if the path points to this host
103 TString fLocalPrefix; // if fIsLocal, prefix to be prepend locally
104
105 void Create(const char *url, TSocket *sock = nullptr);
106 void InitRemoteEntity(const char *url);
107
108public:
110 TNetSystem(const char *url, Bool_t ftpowner = kTRUE);
111 virtual ~TNetSystem();
112
113 Bool_t ConsistentWith(const char *path, void *dirptr) override;
114 Int_t MakeDirectory(const char *name) override;
115 void *OpenDirectory(const char *name) override;
116 void FreeDirectory(void *dirp = nullptr) override;
117 const char *GetDirEntry(void *dirp = nullptr) override;
118 Int_t GetPathInfo(const char *path, FileStat_t &buf) override;
119 Bool_t AccessPathName(const char *path, EAccessMode mode) override;
120 int Unlink(const char *path) override;
121
122 ClassDefOverride(TNetSystem,0) // Directory handler for NetSystem
123};
124
125} // namespace ROOT::Deprecated
126
127using TNetFile R__DEPRECATED(6, 42, "TNetFile is deprecated") = ROOT::Deprecated::TNetFile;
128using TNetSystem R__DEPRECATED(6, 42, "TNetSystem is deprecated") = ROOT::Deprecated::TNetSystem;
129
130#endif
EMessageTypes
#define R__DEPRECATED(MAJOR, MINOR, REASON)
Definition RConfig.hxx:510
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:145
EAccessMode
Definition TSystem.h:51
void Init(Bool_t create) override
Initialize a TNetFile object.
Definition TNetFile.cxx:235
Bool_t ReadBuffer(char *buf, Int_t len) override
Read specified byte range from remote file via rootd daemon.
Definition TNetFile.cxx:299
Bool_t WriteBuffer(const char *buf, Int_t len) override
Write specified byte range to remote file via rootd daemon.
Definition TNetFile.cxx:487
Bool_t Matches(const char *url) override
Return kTRUE if 'url' matches the coordinates of this file.
Definition TNetFile.cxx:760
TNetFile & operator=(const TNetFile &)
virtual void Create(const char *url, Option_t *option, Int_t netopt)
Create a NetFile object.
Definition TNetFile.cxx:658
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
Return file stat information.
Definition TNetFile.cxx:155
Int_t SysClose(Int_t fd) override
Close currently open file.
Definition TNetFile.cxx:143
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:569
void Print(Option_t *option) const override
Print some info about the net file.
Definition TNetFile.cxx:254
Int_t GetErrorCode() const
Definition TNetFile.h:70
Bool_t IsOpen() const override
Retruns kTRUE if file is open, kFALSE otherwise.
Definition TNetFile.cxx:246
Int_t Recv(Int_t &status, EMessageTypes &kind)
Return status from rootd server and message kind.
Definition TNetFile.cxx:545
Int_t ReOpen(Option_t *mode) override
Reopen a file with a different access mode, like from READ to UPDATE or from NEW, CREATE,...
Definition TNetFile.cxx:284
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override
Read a list of buffers given in pos[] and len[] and return it in a single buffer.
Definition TNetFile.cxx:383
void Flush() override
Flush file to disk.
Definition TNetFile.cxx:224
void PrintError(const char *where, Int_t err)
Print error string depending on error code.
Definition TNetFile.cxx:269
const TUrl * GetEndpointUrl() const override
Definition TNetFile.h:80
TNetFile(const TNetFile &)
void Seek(Long64_t offset, ERelativeTo pos=kBeg) override
Set position from where to start reading.
Definition TNetFile.cxx:561
void Close(Option_t *option="") override
Close remote file.
Definition TNetFile.cxx:207
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
Open a remote file. Requires fOption to be set correctly.
Definition TNetFile.cxx:108
virtual ~TNetFile()
TNetFile dtor. Send close message and close socket.
Definition TNetFile.cxx:100
virtual ~TNetSystem()
Destructor.
Definition TNetFile.cxx:935
Bool_t AccessPathName(const char *path, EAccessMode mode) override
Returns FALSE if one can access a file using the specified access mode.
void * GetDirPtr() const override
Definition TNetFile.h:99
void Create(const char *url, TSocket *sock=nullptr)
Create a TNetSystem object.
Definition TNetFile.cxx:857
void * OpenDirectory(const char *name) override
Open a directory and return an opaque pointer to a dir structure.
Definition TNetFile.cxx:981
Int_t GetPathInfo(const char *path, FileStat_t &buf) override
Get info about a file.
Int_t MakeDirectory(const char *name) override
Make a directory via rootd.
Definition TNetFile.cxx:959
Bool_t ConsistentWith(const char *path, void *dirptr) override
Check consistency of this helper with the one required by 'path' or 'dirptr'.
void InitRemoteEntity(const char *url)
Parse and save coordinates of the remote entity (user, host, port, ...)
Definition TNetFile.cxx:833
TNetSystem(const TNetSystem &)=delete
const char * GetDirEntry(void *dirp=nullptr) override
Get directory entry via rootd. Returns 0 in case no more entries.
int Unlink(const char *path) override
Remove a path.
void FreeDirectory(void *dirp=nullptr) override
Free directory via rootd.
TNetSystem & operator=(const TNetSystem &)=delete
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
ERelativeTo
Definition TFile.h:277
@ kBeg
Definition TFile.h:277
This class implements client sockets.
Definition TSocket.h:54
Basic string class.
Definition TString.h:138
Abstract base class defining a generic interface to the underlying Operating System.
Definition TSystem.h:276
This class represents a WWW compatible URL.
Definition TUrl.h:33
@ kUseCompiledDefault
Use the compile-time default setting.
Definition Compression.h:53