XRootD
Loading...
Searching...
No Matches
XrdCpFile Class Reference

#include <XrdCpFile.hh>

+ Collaboration diagram for XrdCpFile:

Public Types

enum  PType {
  isOther = 0 ,
  isDir ,
  isFile ,
  isStdIO ,
  isXroot ,
  isXroots ,
  isHttp ,
  isHttps ,
  isPelican ,
  isS3 ,
  isDevNull ,
  isDevZero
}
 

Public Member Functions

 XrdCpFile ()
 
 XrdCpFile (char *FSpec, struct stat &Stat, short doff, short dlen)
 
 XrdCpFile (const char *FSpec, int &badURL)
 
 ~XrdCpFile ()
 
int Extend (XrdCpFile **pLast, int &nFile, long long &nBytes)
 
int Resolve ()
 

Static Public Member Functions

static void SetMsgPfx (const char *pfx)
 

Public Attributes

short Dlen
 
short Doff
 
long long fSize
 
XrdCpFileNext
 
char * Path
 
char ProtName [8]
 
PType Protocol
 

Detailed Description

Definition at line 36 of file XrdCpFile.hh.

Member Enumeration Documentation

◆ PType

Enumerator
isOther 
isDir 
isFile 
isStdIO 
isXroot 
isXroots 
isHttp 
isHttps 
isPelican 
isS3 
isDevNull 
isDevZero 

Definition at line 40 of file XrdCpFile.hh.

Constructor & Destructor Documentation

◆ XrdCpFile() [1/3]

XrdCpFile::XrdCpFile ( )
inline

Definition at line 59 of file XrdCpFile.hh.

59 : Next(0), Path(0), Doff(0), Dlen(0),
60 Protocol(isOther), fSize(0) {*ProtName = 0;}
short Doff
Definition XrdCpFile.hh:46
PType Protocol
Definition XrdCpFile.hh:49
long long fSize
Definition XrdCpFile.hh:51
char * Path
Definition XrdCpFile.hh:45
char ProtName[8]
Definition XrdCpFile.hh:50
XrdCpFile * Next
Definition XrdCpFile.hh:44
short Dlen
Definition XrdCpFile.hh:47

References Dlen, Doff, fSize, isOther, Next, Path, ProtName, and Protocol.

Referenced by Extend().

+ Here is the caller graph for this function:

◆ XrdCpFile() [2/3]

XrdCpFile::XrdCpFile ( const char * FSpec,
int & badURL )

Definition at line 51 of file XrdCpFile.cc.

52{
53 static struct proto {const char *pHdr; int pHsz; PType pVal;}
54 pTab[] = {{"xroot://", 8, isXroot},
55 {"xroots://", 9, isXroots},
56 {"root://", 7, isXroot},
57 {"roots://", 8, isXroots},
58 {"http://", 7, isHttp},
59 {"pelican://", 10, isPelican},
60 {"s3://", 5, isS3},
61 {"https://", 8, isHttps}
62 };
63 static int pTnum = sizeof(pTab)/sizeof(struct proto);
64 const char *Slash;
65 int i;
66
67// Do some common initialization
68//
69 Doff = 0;
70 Dlen = 0;
71 Next = 0;
72 fSize = 0;
73 badURL= 0;
74 memset(ProtName, 0, sizeof(ProtName));
75
76// Copy out the path and remove trailing slashes (except the last one)
77//
78 Path = strdup(FSpec);
79 i = strlen(Path);
80 while(i) if (Path[i-1] != '/' || (i > 1 && Path[i-2] != '/')) break;
81 else Path[--i] = 0;
82
83// Check for stdin stdout spec
84//
85 if (!strcmp(Path, "-"))
87 return;
88 }
89
90// Dtermine protocol of the incoming spec
91//
92 for (i = 0; i < pTnum; i++)
93 {if (!strncmp(FSpec, pTab[i].pHdr, pTab[i].pHsz))
94 {Protocol = pTab[i].pVal;
95 memcpy(ProtName, pTab[i].pHdr, pTab[i].pHsz-3);
96 return;
97 }
98 }
99
100// See if this is a file
101//
103 if (!strncmp(Path, "file://", 7))
104 {char *pP = Path + 7;
105 if (!strncmp(pP, "localhost", 9)) memmove( Path, pP + 9, strlen( pP + 9 ) + 1 );
106 else if (*pP == '/') memmove( Path, pP, strlen( pP ) + 1 );
107 else {Protocol = isOther;
108 strcpy(ProtName, "remote");
109 return;
110 }
111 }
112
113// Set the default Doff and Dlen assuming non-recursive copy
114//
115 if ((Slash = rindex(Path, '/'))) Dlen = Doff = Slash - Path + 1;
116}

References Dlen, Doff, fSize, isFile, isHttp, isHttps, isOther, isPelican, isS3, isStdIO, isXroot, isXroots, Next, Path, ProtName, and Protocol.

◆ XrdCpFile() [3/3]

XrdCpFile::XrdCpFile ( char * FSpec,
struct stat & Stat,
short doff,
short dlen )

Definition at line 120 of file XrdCpFile.cc.

121 : Next(0), Path(FSpec), Doff(doff), Dlen(dlen),
122 Protocol(isFile), fSize(Stat.st_size)
123 {strcpy(ProtName, "file");}
struct stat Stat
Definition XrdCks.cc:49

References Dlen, Doff, fSize, isFile, Next, Path, ProtName, Protocol, Stat, and stat.

◆ ~XrdCpFile()

XrdCpFile::~XrdCpFile ( )
inline

Definition at line 67 of file XrdCpFile.hh.

67{if (Path) free(Path);}

References Path.

Member Function Documentation

◆ Extend()

int XrdCpFile::Extend ( XrdCpFile ** pLast,
int & nFile,
long long & nBytes )

Definition at line 129 of file XrdCpFile.cc.

130{
131 XrdOucNSWalk nsObj(0, Path, 0, XrdOucNSWalk::retFile|XrdOucNSWalk::Recurse);
132 XrdOucNSWalk::NSEnt *nP, *nnP;
133 XrdCpFile *fP, *pP = this;
134 int rc;
135 short dlen, doff = strlen(Path);
136
137 nsObj.setMsgOn(mPfx);
138
139 while((nP = nsObj.Index(rc)) && rc == 0)
140 {do {dlen = nP->Plen - doff;
141 fP = new XrdCpFile(nP->Path, nP->Stat, doff, dlen);
142 nFile++; nBytes += nP->Stat.st_size; nP->Path = 0;
143 pP->Next = fP; pP = fP;
144 nnP = nP->Next; delete nP;
145 } while((nP = nnP));
146 }
147
148 if (pLast) *pLast = pP;
149 return rc;
150}
static const int retFile
static const int Recurse
struct NSEnt * Next

References XrdCpFile(), XrdOucNSWalk::Index(), Next, XrdOucNSWalk::NSEnt::Next, Path, XrdOucNSWalk::NSEnt::Path, XrdOucNSWalk::NSEnt::Plen, XrdOucNSWalk::Recurse, XrdOucNSWalk::retFile, XrdOucNSWalk::setMsgOn(), and XrdOucNSWalk::NSEnt::Stat.

+ Here is the call graph for this function:

◆ Resolve()

int XrdCpFile::Resolve ( )

Definition at line 156 of file XrdCpFile.cc.

157{
158 struct stat Stat;
159
160// Ignore this call if this is not a file
161//
162 if (Protocol != isFile) return 0;
163
164// This should exist but it might not, the caller will determine what to do
165//
166 char *cgibeg = strchr( Path, '?' );
167 if( cgibeg ) *cgibeg = '\0';
168 if (stat(Path, &Stat)) return errno;
169 if( cgibeg ) *cgibeg = '?';
170
171// Find out what this really is
172//
173 if (S_ISREG(Stat.st_mode)) fSize = Stat.st_size;
174 else if (S_ISDIR(Stat.st_mode)) Protocol = isDir;
175 else if (!strcmp(Path, "/dev/null")) Protocol = isDevNull;
176 else if (!strcmp(Path, "/dev/zero")) Protocol = isDevZero;
177 else return ENOTSUP;
178
179// All is well
180//
181 return 0;
182}
#define stat(a, b)
Definition XrdPosix.hh:101

References fSize, isDevNull, isDevZero, isDir, isFile, Path, Protocol, Stat, and stat.

◆ SetMsgPfx()

static void XrdCpFile::SetMsgPfx ( const char * pfx)
inlinestatic

Definition at line 57 of file XrdCpFile.hh.

57{mPfx = pfx;}

Referenced by XrdCpConfig::XrdCpConfig().

+ Here is the caller graph for this function:

Member Data Documentation

◆ Dlen

short XrdCpFile::Dlen

Definition at line 47 of file XrdCpFile.hh.

Referenced by XrdCpFile(), XrdCpFile(), XrdCpFile(), and main().

◆ Doff

short XrdCpFile::Doff

Definition at line 46 of file XrdCpFile.hh.

Referenced by XrdCpFile(), XrdCpFile(), XrdCpFile(), AdjustFileInfo(), IndexRemote(), and main().

◆ fSize

long long XrdCpFile::fSize

Definition at line 51 of file XrdCpFile.hh.

Referenced by XrdCpFile(), XrdCpFile(), XrdCpFile(), and Resolve().

◆ Next

XrdCpFile* XrdCpFile::Next

◆ Path

char* XrdCpFile::Path

◆ ProtName

char XrdCpFile::ProtName[8]

Definition at line 50 of file XrdCpFile.hh.

Referenced by XrdCpFile(), XrdCpFile(), XrdCpFile(), and main().

◆ Protocol

PType XrdCpFile::Protocol

Definition at line 49 of file XrdCpFile.hh.

Referenced by XrdCpFile(), XrdCpFile(), XrdCpFile(), main(), and Resolve().


The documentation for this class was generated from the following files: