75 :
TFile(
url,
strstr(
option,
"_WITHOUT_GLOBALREGISTRATION") != nullptr ?
"NET_WITHOUT_GLOBALREGISTRATION" :
"NET",
112 Create(fUrl.GetUrl(), fOption, fNetopt);
113 if (!fSocket)
return -1;
117 if (fProtocol > 15) {
118 fSocket->Send(
Form(
"%s %s", fUrl.GetFile(),
ToLower(fOption).Data()),
122 fSocket->Send(
Form(
"/%s %s", fUrl.GetFile(),
ToLower(fOption).Data()),
131 PrintError(
"SysOpen", stat);
157 if (fProtocol < 3)
return 1;
159 if (!fSocket)
return 1;
165 fSocket->Recv(
msg,
sizeof(
msg), kind);
170 if (fProtocol > 12) {
173 &uid, &gid,
size, modtime, &islink);
176 &uid, &gid,
size, modtime, &islink);
209 if (!fSocket)
return;
228 if (fSocket && fWritable)
256 const char *
fname = fUrl.GetFile();
259 Printf(
"Remote user: %s", fUser.Data());
260 Printf(
"Title: %s", fTitle.Data());
261 Printf(
"Option: %s", fOption.Data());
262 Printf(
"Bytes written: %lld", fBytesWrite);
263 Printf(
"Bytes read: %lld", fBytesRead);
287 Error(
"ReOpen",
"operation not supported by remote rootd (protocol = %d)",
301 if (!fSocket)
return kTRUE;
308 if ((
st = ReadBufferViaCache(buf,
len))) {
321 Error(
"ReadBuffer",
"error sending kROOTD_GET command");
330 if (Recv(stat, kind) < 0 || kind ==
kROOTD_ERR) {
331 PrintError(
"ReadBuffer", stat);
340 Error(
"ReadBuffer",
"error receiving buffer of length %d, got %d",
len,
n);
350 SetFileBytesRead(GetFileBytesRead() +
len);
351 SetFileReadCalls(GetFileReadCalls() + 1);
385 if (!fSocket)
return kTRUE;
392 Int_t blockSize = 262144;
407 data_buf += pos[i] + fArchiveOffset;
417 Error(
"ReadBuffers",
"error sending kROOTD_GETS command");
423 Error(
"ReadBuffers",
"error sending buffer");
429 if (Recv(stat, kind) < 0 || kind ==
kROOTD_ERR) {
430 PrintError(
"ReadBuffers", stat);
438 if (left > blockSize)
447 Error(
"GetBuffers",
"error receiving buffer of length %d, got %d",
458 SetFileBytesRead(GetFileBytesRead() +
total_len);
459 SetFileReadCalls(GetFileReadCalls() + 1);
476 Info(
"ReadBuffers",
"Couldnt use the specific implementation, calling TFile::ReadBuffers");
489 if (!fSocket || !fWritable)
return kTRUE;
494 if ((
st = WriteBufferViaCache(buf,
len))) {
504 Error(
"WriteBuffer",
"error sending kROOTD_PUT command");
508 if (fSocket->SendRaw(buf,
len) < 0) {
510 Error(
"WriteBuffer",
"error sending buffer");
519 if (Recv(stat, kind) < 0 || kind ==
kROOTD_ERR) {
521 PrintError(
"WriteBuffer", stat);
530 SetFileBytesWritten(GetFileBytesWritten() +
len);
550 if (!fSocket)
return -1;
578 if (
url.Contains(
"root")) {
584 fUrl.GetUser(), fUrl.GetHost(), fUrl.GetPort()));
588 Error(
"TNetFile",
"can't open %d-stream connection to rootd on "
589 "host %s at port %d",
sSize, fUrl.GetHost(), fUrl.GetPort());
591 Error(
"TNetFile",
"can't open connection to rootd on "
592 "host %s at port %d", fUrl.GetHost(), fUrl.GetPort());
598 fProtocol = fSocket->GetRemoteProtocol();
600 Warning(
"ConnectServer",
"rootd does not support \"+read\" option");
609 fSocket->Send(
Form(
"%s %s",
fn.Data(),
614 fSocket->Send(
Form(
"%s %s",
fn.Data(),
685 if (fOption ==
"NEW")
695 if (!fUrl.IsValid()) {
696 Error(
"Create",
"invalid URL specified: %s", fUrl.GetUrl());
707 if (
gDebug > 2)
Info(
"Create",
"got from host %d %d", stat, kind);
710 PrintError(
"Create", stat);
711 Error(
"Create",
"failing on file %s", fUrl.GetUrl());
770 if (!
strcmp(
u.GetFile(),fEndpointUrl.GetFile())) {
775 if (
u.GetPort() == fEndpointUrl.GetPort()) {
798 :
TSystem(
"-root",
"Net file Helper System")
820 :
TSystem(
"-root",
"Net file Helper System")
838 fUser =
turl.GetUser();
839 if (!fUser.Length()) {
847 fHost =
turl.GetHostFQDN();
851 fPort =
turl.GetPort();
862 if (!
surl.Contains(
"://")) {
863 surl.Insert(
surl.Index(
":")+1,
"//");
877 if (
opts.Contains(
"remote=1"))
879 else if (
opts.Contains(
"remote=0"))
890 InitRemoteEntity(
surl);
893 if (fHost.Length()) {
913 if (fFTP && fFTP->IsOpen()) {
914 if (fFTP->GetSocket()->GetRemoteProtocol() < 12) {
916 "remote daemon does not support 'system' functionality");
926 gROOT->GetListOfSockets()->Remove(fFTP);
940 if (fFTP->IsOpen()) {
944 fFTP->FreeDirectory(
kFALSE);
964 if (!fLocalPrefix.IsNull())
965 edir.Insert(0, fLocalPrefix);
969 if (fFTP && fFTP->IsOpen()) {
986 if (!fLocalPrefix.IsNull())
987 edir.Insert(0, fLocalPrefix);
991 if (!fFTP || !fFTP->IsOpen())
996 Info(
"OpenDirectory",
"a directory is already open: close it first");
997 fFTP->FreeDirectory(
kFALSE);
1006 fDirp = (
void *)&fDir;
1023 if (
dirp != fDirp) {
1024 Error(
"FreeDirectory",
"invalid directory pointer (should never happen)");
1028 if (fFTP && fFTP->IsOpen()) {
1030 fFTP->FreeDirectory(
kFALSE);
1047 if (
dirp != fDirp) {
1048 Error(
"GetDirEntry",
"invalid directory pointer (should never happen)");
1052 if (fFTP && fFTP->IsOpen() && fDir) {
1053 return fFTP->GetDirEntry(
kFALSE);
1069 if (!fLocalPrefix.IsNull())
1070 epath.Insert(0, fLocalPrefix);
1074 if (fFTP && fFTP->IsOpen()) {
1093 if (!fLocalPrefix.IsNull())
1094 epath.Insert(0, fLocalPrefix);
1098 if (fFTP && fFTP->IsOpen()) {
1118 if (path &&
strlen(path)) {
1123 if (user.
IsNull() && !fUser.IsNull()) {
1136 Info(
"ConsistentWith",
"fUser:'%s' (%s), fHost:'%s' (%s), fPort:%d (%d)",
1137 fUser.Data(), user.
Data(), fHost.Data(), host.
Data(),
1140 if (user == fUser && host == fHost && port == fPort)
1155 if (!fLocalPrefix.IsNull())
1156 epath.Insert(0, fLocalPrefix);
1161 Warning(
"Unlink",
"functionality not implemented - ignored (path: %s)", path);
R__EXTERN const char * gRootdErrStr[]
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char)
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
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 result
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
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
void ReadBuffer(char *&buffer) override
TString ToLower(const TString &s)
Return a lower-case version of str.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Bool_t R_ISREG(Int_t mode)
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
void Init(Bool_t create) override
Initialize a TNetFile object.
Bool_t ReadBuffer(char *buf, Int_t len) override
Read specified byte range from remote file via rootd daemon.
Bool_t WriteBuffer(const char *buf, Int_t len) override
Write specified byte range to remote file via rootd daemon.
Bool_t Matches(const char *url) override
Return kTRUE if 'url' matches the coordinates of this file.
virtual void Create(const char *url, Option_t *option, Int_t netopt)
Create a NetFile object.
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
Return file stat information.
Int_t SysClose(Int_t fd) override
Close currently open file.
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.
void Print(Option_t *option) const override
Print some info about the net file.
Bool_t IsOpen() const override
Retruns kTRUE if file is open, kFALSE otherwise.
Int_t Recv(Int_t &status, EMessageTypes &kind)
Return status from rootd server and message kind.
Int_t ReOpen(Option_t *mode) override
Reopen a file with a different access mode, like from READ to UPDATE or from NEW, CREATE,...
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.
void Flush() override
Flush file to disk.
void PrintError(const char *where, Int_t err)
Print error string depending on error code.
void Seek(Long64_t offset, ERelativeTo pos=kBeg) override
Set position from where to start reading.
void Close(Option_t *option="") override
Close remote file.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
Open a remote file. Requires fOption to be set correctly.
virtual ~TNetFile()
TNetFile dtor. Send close message and close socket.
virtual ~TNetSystem()
Destructor.
Bool_t AccessPathName(const char *path, EAccessMode mode) override
Returns FALSE if one can access a file using the specified access mode.
void Create(const char *url, TSocket *sock=nullptr)
Create a TNetSystem object.
void * OpenDirectory(const char *name) override
Open a directory and return an opaque pointer to a dir structure.
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.
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, ...)
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.
TSignalHandler * GetSignalHandler() const
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
virtual Bool_t Matches(const char *name)
Return kTRUE if 'url' matches the coordinates of this file.
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
virtual void Init(Bool_t create)
Initialize a TFile object.
void Close(Option_t *option="") override
Close a file.
virtual void SetName(const char *name)
Set the name of the TNamed.
void HandleDelayedSignal()
This class implements client sockets.
const char * GetUrl() const
const char * Data() const
Abstract base class defining a generic interface to the underlying Operating System.
virtual void IgnoreInterrupt(Bool_t ignore=kTRUE)
If ignore is true ignore the interrupt signal, else restore previous behaviour.
static void ResetErrno()
Static function resetting system error number.
static Int_t GetErrno()
Static function returning system error number.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual int MakeDirectory(const char *name)
Make a directory.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
virtual Bool_t ConsistentWith(const char *path, void *dirptr=nullptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
The TTimeStamp encapsulates seconds and ns since EPOCH.
This class represents a WWW compatible URL.
const char * GetFile() const
const char * GetOptions() const
static TSocket * CreateAuthSocket(const char *user, const char *host, Int_t port, Int_t size=0, Int_t tcpwindowsize=-1, TSocket *s=nullptr, Int_t *err=nullptr)
Creates a socket or a parallel socket and authenticates to the remote server specified in 'url' on re...
static Bool_t IsAuthenticated(const TSocket &s)
static TSecContext * GetSecContext(const TSocket &s)