XRootD
Loading...
Searching...
No Matches
XrdOucN2N Class Reference
+ Inheritance diagram for XrdOucN2N:
+ Collaboration diagram for XrdOucN2N:

Public Member Functions

 XrdOucN2N (XrdSysError *erp, const char *lpfx, const char *rpfx)
 
virtual int lfn2pfn (const char *lfn, char *buff, int blen)
 
virtual int lfn2rfn (const char *lfn, char *buff, int blen)
 
virtual std::vector< std::string * > * n2nVec (const char *lfn)
 
virtual int pfn2lfn (const char *lfn, char *buff, int blen)
 
- Public Member Functions inherited from XrdOucName2Name
 XrdOucName2Name ()
 Constructor.
 
virtual ~XrdOucName2Name ()
 Destructor.
 
- Public Member Functions inherited from XrdOucName2NameVec
 XrdOucName2NameVec ()
 Constructor and Destructor.
 
virtual ~XrdOucName2NameVec ()
 
virtual void Recycle (std::vector< std::string * > *nvP)
 

Detailed Description

Definition at line 50 of file XrdOucName2Name.cc.

Constructor & Destructor Documentation

◆ XrdOucN2N()

XrdOucN2N::XrdOucN2N ( XrdSysError erp,
const char *  lpfx,
const char *  rpfx 
)

Definition at line 82 of file XrdOucName2Name.cc.

83{
84 eDest = erp;
85
86// Local root must not have any trailing slahes
87//
88 if (!lpfx) {LocalRoot = 0; LocalRootLen = 0;}
89 else if (!(LocalRootLen = strlen(lpfx))) LocalRoot = 0;
90 else {LocalRoot = strdup(lpfx);
91 while(LocalRootLen && LocalRoot[LocalRootLen-1] == '/')
92 {LocalRootLen--; LocalRoot[LocalRootLen] = '\0';}
93 }
94
95// Remote root must not have any trailing slases unless it a URL
96//
97 if (!rpfx) {RemotRoot = 0; RemotRootLen = 0;}
98 else if (!(RemotRootLen = strlen(rpfx))) RemotRoot = 0;
99 else {RemotRoot = strdup(rpfx);
100 if (*RemotRoot == '/')
101 while(RemotRootLen && RemotRoot[RemotRootLen-1] == '/')
102 {RemotRootLen--; RemotRoot[RemotRootLen] = '\0';}
103 }
104}

Member Function Documentation

◆ lfn2pfn()

int XrdOucN2N::lfn2pfn ( const char *  lfn,
char *  buff,
int  blen 
)
virtual

Map a logical file name to a physical file name.

Parameters
lfn-> Logical file name.
buff-> Buffer where the physical file name of an existing file is to be placed. It must end with a null byte.
blenThe length of the buffer.
Returns
Success: Zero. Failure: An errno number describing the failure; typically EINVAL - The supplied lfn is invalid. ENAMETOOLONG - The buffer is too small for the pfn.

Implements XrdOucName2Name.

Definition at line 110 of file XrdOucName2Name.cc.

111{
112 if (concat_fn(LocalRoot, LocalRootLen, lfn, buff, blen))
113 return eDest->Emsg("glp",-ENAMETOOLONG,"generate local path",lfn);
114 return 0;
115}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

References XrdSysError::Emsg().

Referenced by n2nVec().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lfn2rfn()

int XrdOucN2N::lfn2rfn ( const char *  lfn,
char *  buff,
int  blen 
)
virtual

Map a logical file name to the name the file would have in a remote storage system (e.g. Mass Storage System at a remote location).

Parameters
lfn-> Logical file name.
buff-> Buffer where the remote file name is to be placed. It need not actually exist in that location but could be created there with that name. It must end with a null byte.
blenThe length of the buffer.
Returns
Success: Zero. Failure: An errno number describing the failure; typically EINVAL - The supplied lfn is invalid. ENAMETOOLONG - The buffer is too small for the pfn.

Implements XrdOucName2Name.

Definition at line 121 of file XrdOucName2Name.cc.

122{
123 if (concat_fn(RemotRoot, RemotRootLen, lfn, buff, blen))
124 return eDest->Emsg("grp",-ENAMETOOLONG,"generate remote path",lfn);
125 return 0;
126}

References XrdSysError::Emsg().

+ Here is the call graph for this function:

◆ n2nVec()

std::vector< std::string * > * XrdOucN2N::n2nVec ( const char *  lfn)
virtual

Map a logical file name to all of its possible physical file names.

Parameters
lfn-> Logical file name.
Returns
Success: Pointer to a vector of strings of physical file names. Failure: A nil pointer indicating that no translation exists.

Implements XrdOucName2NameVec.

Definition at line 171 of file XrdOucName2Name.cc.

172{
173 char pfnBuff[2048];
174 std::string *s;
175
176// Perform translation
177//
178 if (lfn2pfn(lfn, pfnBuff, sizeof(pfnBuff))) return 0;
179
180// Return a vector of one
181//
182 s = new std::string(pfnBuff);
183 return new std::vector<std::string *>(1, s);
184}
virtual int lfn2pfn(const char *lfn, char *buff, int blen)

References lfn2pfn().

+ Here is the call graph for this function:

◆ pfn2lfn()

int XrdOucN2N::pfn2lfn ( const char *  pfn,
char *  buff,
int  blen 
)
virtual

Map a physical file name to it's logical file name.

Parameters
pfn-> Physical file name. This is always a valid name of either an existing file or a file that could been created.
buff-> Buffer where the logical file name is to be placed. It need not actually exist but could be created with that name. It must end with a null byte.
blenThe length of the buffer.
Returns
Success: Zero. Failure: An errno number describing the failure; typically EINVAL - The supplied lfn is invalid. ENAMETOOLONG - The buffer is too small for the pfn.

Implements XrdOucName2Name.

Definition at line 153 of file XrdOucName2Name.cc.

154{
155 char *tp;
156
157 if (!LocalRoot
158 || strncmp(pfn, LocalRoot, LocalRootLen)
159 || pfn[LocalRootLen] != '/')
160 tp = (char *)pfn;
161 else tp = (char *)(pfn+LocalRootLen);
162
163 if (strlcpy(buff, tp, blen) >= (unsigned int)blen) return ENAMETOOLONG;
164 return 0;
165}
size_t strlcpy(char *dst, const char *src, size_t sz)

References strlcpy().

+ Here is the call graph for this function:

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