32# include <sys/types.h>
47#if defined(R__UNIX) || defined(R__MACOSX)
82 "url must be of the form \"[root[up,s,k,g,h,ug]://]host[:port]\"");
99 if (
hurl.Contains(
"root")) {
105 url.GetUser(),
url.GetHost(),
url.GetPort()));
109 Error(
"TFTP",
"can't open %d-stream connection to rootd on "
110 "host %s at port %d", par,
url.GetHost(),
url.GetPort());
112 Error(
"TFTP",
"can't open connection to rootd on "
113 "host %s at port %d",
url.GetHost(),
url.GetPort());
137 gROOT->GetListOfSockets()->Add(
this);
165 Printf(
"Security context: %s",
174 Printf(
"Transfer mode: %s",
fMode ?
"ascii" :
"binary");
209 if (blockSize < 32768) {
215 for (i = 0; i <
int(
sizeof(blockSize)*8); i++)
216 if ((blockSize >> i) == 1)
235 if (!
IsOpen() || !file || !*file)
return -1;
237#if defined(R__WIN32) || defined(R__WINGCC)
239#elif defined(R__SEEK64)
245 Error(
"PutFile",
"cannot open %s in read mode", file);
253 Error(
"PutFile",
"%s not a regular file (%ld)", file, flags);
258 Warning(
"PutFile",
"could not stat %s", file);
274 Error(
"PutFile",
"error sending kROOTD_PUTFILE command");
288 Info(
"PutFile",
"sending file %s (%lld bytes, starting at %lld)",
299#if defined(R__SEEK64)
301#elif defined(R__WIN32)
313#if defined(R__SEEK64)
318 if (buf == (
char *) -1) {
319 Error(
"PutFile",
"mmap of file %s failed", file);
327 if (
siz < 0 ||
siz != left) {
328 Error(
"PutFile",
"error reading from file %s", file);
337 Error(
"PutFile",
"error sending buffer");
383 Info(
"PutFile",
"%.3f seconds, %.2f Mbytes per second",
385 else if (
speed > 512)
386 Info(
"PutFile",
"%.3f seconds, %.2f Kbytes per second",
389 Info(
"PutFile",
"%.3f seconds, %.2f bytes per second",
408 if (!
IsOpen() || !file || !*file)
return -1;
421 Error(
"GetFile",
"error sending kROOTD_GETFILE command");
439 Error(
"GetFile",
"error receiving remote file size");
455#if defined(R__WIN32) || defined(R__WINGCC)
462#elif defined(R__SEEK64)
468#if defined(R__WIN32) || defined(R__WINGCC)
473#elif defined(R__SEEK64)
498 Warning(
"GetFile",
"could not determine if there is enough free space to store file");
503#if defined(R__SEEK64)
505#elif defined(R__WIN32)
510 Error(
"GetFile",
"cannot seek to position %lld in file %s",
518 Info(
"GetFile",
"getting file %s (%lld bytes, starting at %lld)",
543 Error(
"GetFile",
"error receiving buffer of length %d, got %d",
546 delete [] buf;
delete []
buf2;
558 buf2[
j++] = buf[i++];
572 delete [] buf;
delete []
buf2;
577 Error(
"GetFile",
"error writing all requested bytes to file %s, wrote %ld of %d",
581 delete [] buf;
delete []
buf2;
594 delete [] buf;
delete []
buf2;
611 Info(
"GetFile",
"%.3f seconds, %.2f Mbytes per second",
613 else if (
speed > 512)
614 Info(
"GetFile",
"%.3f seconds, %.2f Kbytes per second",
617 Info(
"GetFile",
"%.3f seconds, %.2f bytes per second",
633 Error(
"ChangeDirectory",
"illegal directory name specified");
638 Error(
"ChangeDirectory",
"error sending kROOTD_CHDIR command");
646 Error(
"ChangeDirectory",
"error receiving chdir confirmation");
653 Error(
"ChangeDirectory",
"error receiving chdir confirmation");
658 Info(
"ChangeDirectory",
"%s",
mess);
672 Error(
"MakeDirectory",
"illegal directory name specified");
677 Error(
"MakeDirectory",
"error sending kROOTD_MKDIR command");
685 Error(
"MakeDirectory",
"error receiving mkdir confirmation");
707 Error(
"DeleteDirectory",
"illegal directory name specified");
712 Error(
"DeleteDirectory",
"error sending kROOTD_RMDIR command");
720 Error(
"DeleteDirectory",
"error receiving rmdir confirmation");
724 Info(
"DeleteDirectory",
"%s",
mess);
742 Error(
"ListDirectory",
"error sending kROOTD_LSDIR command");
751 Error(
"ListDirectory",
"error receiving lsdir confirmation");
769 Error(
"DeleteDirectory",
"error sending kROOTD_PWD command");
777 Error(
"PrintDirectory",
"error receiving pwd confirmation");
795 Error(
"RenameFile",
"illegal file names specified");
800 Error(
"RenameFile",
"error sending kROOTD_MV command");
808 Error(
"RenameFile",
"error receiving mv confirmation");
825 if (!file || !*file) {
826 Error(
"DeleteFile",
"illegal file name specified");
831 Error(
"DeleteFile",
"error sending kROOTD_RM command");
839 Error(
"DeleteFile",
"error receiving rm confirmation");
857 if (!file || !*file) {
858 Error(
"ChangePermission",
"illegal file name specified");
863 Error(
"ChangePermission",
"error sending kROOTD_CHMOD command");
871 Error(
"ChangePermission",
"error receiving chmod confirmation");
875 Info(
"ChangePermission",
"%s",
mess);
889 Error(
"Close",
"error sending kROOTD_CLOSE command");
900 gROOT->GetListOfSockets()->Remove(
this);
921 Error(
"OpenDirectory",
"call not supported by remote rootd");
926 Error(
"OpenDirectory",
"illegal directory name specified");
931 Error(
"OpenDirectory",
"error sending kROOTD_OPENDIR command");
939 Error(
"OpenDirectory",
"error receiving opendir confirmation");
961 Error(
"FreeDirectory",
"call not supported by remote rootd");
966 Error(
"FreeDirectory",
"error sending kROOTD_FREEDIR command");
974 Error(
"FreeDirectory",
"error receiving freedir confirmation");
990 static char dirent[1024] = {0};
995 Error(
"GetDirEntry",
"call not supported by remote rootd");
1000 Error(
"GetDirEntry",
"error sending kROOTD_DIRENTRY command");
1008 Error(
"GetDirEntry",
"error receiving dir entry confirmation");
1017 return (
const char *)
dirent;
1036 Error(
"GetPathInfo",
"call not supported by remote rootd");
1040 if (!path || !*path) {
1041 Error(
"GetPathInfo",
"illegal path name specified");
1046 Error(
"GetPathInfo",
"error sending kROOTD_FSTAT command");
1054 Error(
"GetPathInfo",
"error receiving fstat confirmation");
1066 &uid, &gid, &
size, &mtime, &islink);
1069 &uid, &gid, &
size, &mtime, &islink);
1089 buf.
fDev = (
id >> 24);
1090 buf.
fIno = (
id & 0x00FFFFFF);
1116 Error(
"AccessPathName",
"call not supported by remote rootd");
1120 if (!path || !*path) {
1121 Error(
"AccessPathName",
"illegal path name specified");
1126 Error(
"AccessPathName",
"error sending kROOTD_ACCESS command");
1134 Error(
"AccessPathName",
"error receiving access confirmation");
1138 Info(
"AccessPathName",
"%s",
mess);
R__EXTERN const char * gRootdErrStr[]
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char mode
R__EXTERN TVirtualMutex * gROOTMutex
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.
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD(mutex)
Int_t MakeDirectory(const char *dir, Bool_t print=kFALSE) const
Make a remote directory.
Int_t DeleteDirectory(const char *dir) const
Delete a remote directory.
Long64_t PutFile(const char *file, const char *remoteName=nullptr)
Transfer file to remote host.
Int_t DeleteFile(const char *file) const
Delete a remote file.
void PrintError(const char *where, Int_t err) const
Print error string depending on error code.
Int_t Recv(Int_t &status, EMessageTypes &kind) const
Return status from rootd server and message kind.
void Print(Option_t *opt="") const override
Print some info about the FTP connection.
void Init(const char *url, Int_t parallel, Int_t wsize)
Set up the actual connection.
Long64_t GetFile(const char *file, const char *localName=nullptr)
Transfer file from remote host.
void FreeDirectory(Bool_t print=kFALSE)
Free a remotely open directory via rootd.
Int_t GetPathInfo(const char *path, FileStat_t &buf, Bool_t print=kFALSE)
Get info about a file.
Int_t RenameFile(const char *file1, const char *file2) const
Rename a remote file.
static Long64_t fgBytesRead
Bool_t OpenDirectory(const char *name, Bool_t print=kFALSE)
Open a directory via rootd.
Int_t PrintDirectory() const
Print path of remote working directory.
Int_t ListDirectory(Option_t *cmd="") const
List remote directory.
void SetBlockSize(Int_t blockSize)
Make sure the block size is a power of two, with a minimum of 32768.
Int_t ChangePermission(const char *file, Int_t mode) const
Change permissions of a remote file.
const char * GetDirEntry(Bool_t print=kFALSE)
Get directory entry via rootd.
Int_t Close()
Close ftp connection.
Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists, Bool_t print=kFALSE)
Returns kFALSE if one can access a file using the specified access mode.
Int_t ChangeDirectory(const char *dir) const
Change the remote directory.
virtual ~TFTP()
TFTP dtor. Send close message and close socket.
Long64_t fBytesWrite
connection to rootd
static Long64_t fgBytesWrite
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
const char * GetUser() const
virtual const char * AsString(TString &out)
Returns short string with relevant information about this security context.
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Int_t GetRemoteProtocol() const
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
TSecContext * GetSecContext() const
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
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...
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
virtual Bool_t IsAuthenticated() const
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: fs type, block size, number of blocks, number of free blocks.
static void ResetErrno()
Static function resetting system error number.
static Int_t GetErrno()
Static function returning system error number.
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 const char * HostName()
Return the system's host name.
This class represents a WWW compatible URL.