XRootD
XrdOucFileInfo Class Reference

#include <XrdOucFileInfo.hh>

+ Collaboration diagram for XrdOucFileInfo:

Public Member Functions

 XrdOucFileInfo (const char *lfn=0)
 
 ~XrdOucFileInfo ()
 Destructor. More...
 
void AddDigest (const char *hname, const char *hval)
 
void AddFileName (const char *filename)
 
void AddLfn (const char *lfn)
 
void AddProtocol (const char *protname)
 
void AddUrl (const char *url, const char *cntry=0, int prty=0, bool fifo=true)
 
const char * GetDigest (const char *&hval, bool xrdname=true)
 
const char * GetLfn ()
 
long long GetSize ()
 
const char * GetTargetName ()
 
const char * GetUrl (char *cntry=0, int *prty=0)
 
bool HasProtocol (const char *protname)
 
void SetSize (long long fsz)
 

Public Attributes

XrdOucFileInfonextFile
 Link field to simply miltiple file processing. More...
 

Detailed Description

Definition at line 45 of file XrdOucFileInfo.hh.

Constructor & Destructor Documentation

◆ XrdOucFileInfo()

XrdOucFileInfo::XrdOucFileInfo ( const char *  lfn = 0)
inline

Constructor

Parameters
lfnAn optional logical file name associated with this file.

Definition at line 178 of file XrdOucFileInfo.hh.

179  : nextFile(0), fHash(0), fHashNext(0),
180  fUrl(0), fUrlNext(0), fTargetName(0), fSize(-1)
181  {if (lfn) fLfn = strdup(lfn);
182  else fLfn = 0;
183  }
XrdOucFileInfo * nextFile
Link field to simply miltiple file processing.

◆ ~XrdOucFileInfo()

XrdOucFileInfo::~XrdOucFileInfo ( )

Destructor.

Definition at line 88 of file XrdOucFileInfo.cc.

89 {
90  XrdOucFIHash *hdP, *hP = fHash;
91  XrdOucFIUrl *udP, *uP = fUrl;
92 
93 // Destroy the hash list
94 //
95  while((hdP = hP)) {hP = hP->next; delete hdP;}
96 
97 // Destroy the url list
98 //
99  while((udP = uP)) {uP = uP->next; delete udP;}
100 
101 // Free the memory allocated for fTargetName
102 //
103  if( fTargetName ) free(fTargetName);
104 
105 // Free memory allocated to the lfn
106 //
107  if(fLfn) free(fLfn);
108 }
XrdOucFIHash * next
XrdOucFIUrl * next

References XrdOucFIHash::next, and XrdOucFIUrl::next.

Member Function Documentation

◆ AddDigest()

void XrdOucFileInfo::AddDigest ( const char *  hname,
const char *  hval 
)

Add a digest to the file descriptions.

Parameters
hnamePoiner to hash name.
hvalPoiner to hash value.

Definition at line 114 of file XrdOucFileInfo.cc.

115 {
116  int n;
117 
118 // Chain in a new digest
119 //
120  fHashNext = fHash = new XrdOucFIHash(hname, hval, fHash);
121 
122 // Now make sure the hash type is lower case
123 //
124  n = strlen(hname);
125  for (int i = 0; i < n; i++) fHash->hName[i] = tolower(fHash->hName[i]);
126 }

References XrdOucFIHash::hName.

◆ AddFileName()

void XrdOucFileInfo::AddFileName ( const char *  filename)

Add target filename to the file descriptions.

Parameters
filenamePoiner to file name.

Definition at line 166 of file XrdOucFileInfo.cc.

167 {
168  if(fTargetName) {free(fTargetName); fTargetName = 0;}
169 
170  if(filename)
171  fTargetName = strdup(filename);
172 }

◆ AddLfn()

void XrdOucFileInfo::AddLfn ( const char *  lfn)

Add logical filename to the file descriptions.

Parameters
lfnPoiner to logical file name.

Definition at line 178 of file XrdOucFileInfo.cc.

179 {
180  if(fLfn) {free(fLfn); fLfn = 0;}
181 
182  if(lfn)
183  fLfn = strdup(lfn);
184 }

◆ AddProtocol()

void XrdOucFileInfo::AddProtocol ( const char *  protname)

Add protocol to the list of available protocols.

Parameters
protnamePoiner to protocol name ending with a colon

Definition at line 190 of file XrdOucFileInfo.cc.

191 {
192  if (protList.find(protname) == std::string::npos) protList.append(protname);
193 }

Referenced by XrdXmlMetaLink::Convert().

+ Here is the caller graph for this function:

◆ AddUrl()

void XrdOucFileInfo::AddUrl ( const char *  url,
const char *  cntry = 0,
int  prty = 0,
bool  fifo = true 
)

Add a url to the file descriptions.

Parameters
urlPoiner to file url.
cntryPoiner to the optional 2-char null terminated country code. Upper case country codes are converted to lower case.
prtySelection priority. If less than 0 it is set to zero. Urls are placed in increasing prty order (0 is top priority).
fifoWhen true, the location is placed at the end of locations of equal pririoty. Otherwise, is is placed at the head.

Definition at line 132 of file XrdOucFileInfo.cc.

134 {
135  XrdOucFIUrl *urlP = new XrdOucFIUrl(url, cntry, prty);
136  XrdOucFIUrl *unP = fUrl, *upP = 0;
137 
138 // If a country code was specified, convert it to lower case
139 //
140  if (cntry)
141  {urlP->fCC[0] = tolower(cntry[0]);
142  urlP->fCC[1] = tolower(cntry[1]);
143  urlP->fCC[2] = urlP->fCC[3] = 0;
144  } else strcpy(urlP->fCC, "us");
145 
146 // Find location to insert this url
147 //
148  if (fifo)
149  {while(unP && prty >= unP->fPrty) {upP = unP; unP = unP->next;}
150  } else {
151  while(unP && prty > unP->fPrty) {upP = unP; unP = unP->next;}
152  }
153 
154 // Do the insert
155 //
156  urlP->next = unP;
157  if (upP) upP->next = urlP;
158  else fUrl = urlP;
159  if (fUrl != fUrlNext) fUrlNext = fUrl;
160 }

References XrdOucFIUrl::fCC, XrdOucFIUrl::fPrty, and XrdOucFIUrl::next.

Referenced by XrdXmlMetaLink::Convert().

+ Here is the caller graph for this function:

◆ GetDigest()

const char * XrdOucFileInfo::GetDigest ( const char *&  hval,
bool  xrdname = true 
)

Obtain the next digest that can be used to validate the file.

Parameters
hvalPlace to put the pointer to the hash value in ASCII encoded hex,
xrdnameWhen true the corresponding name expected by XRootD is returned
Returns
Pointer to the hash name. The name and value are valid until this object is deleted. If no more hashes exist, a nil pointer is returned. A subsequent call will start at the front of the list.

Definition at line 199 of file XrdOucFileInfo.cc.

200 {
201  XrdOucFIHash *hP;
202 
203 // Check if we are at the end
204 //
205  if (!fHashNext) {fHashNext = fHash; return 0;}
206 
207 // Skip to next hash for subsequent call
208 //
209  hP = fHashNext; fHashNext = fHashNext->next;
210 
211 // Return the appropriate values
212 //
213  hval = hP->hValue;
214  return (xrdname ? hP-> XrdhName() : hP->hName);
215 }

References XrdOucFIHash::hName, XrdOucFIHash::hValue, and XrdOucFIHash::next.

◆ GetLfn()

const char* XrdOucFileInfo::GetLfn ( )
inline

Obtain the logical file name associated with this file.

Returns
Pointer to the lfn. The lfn is valid until this object is deleted. A nil pointer indicates that no lfn has been specified.

Definition at line 119 of file XrdOucFileInfo.hh.

119 {return fLfn;}

Referenced by XrdXmlMetaLink::Convert().

+ Here is the caller graph for this function:

◆ GetSize()

long long XrdOucFileInfo::GetSize ( )
inline

Get file size.

Returns
The size of the file. If it is negative the size has not been set.

Definition at line 135 of file XrdOucFileInfo.hh.

135 {return fSize;}

◆ GetTargetName()

const char* XrdOucFileInfo::GetTargetName ( )
inline

Obtain the target file name.

Returns
Pointer to the target file name. The target filename is valid until this object is deleted.

Definition at line 127 of file XrdOucFileInfo.hh.

127 {return fTargetName;}

◆ GetUrl()

const char * XrdOucFileInfo::GetUrl ( char *  cntry = 0,
int *  prty = 0 
)

Obtain the next url for this file.

Parameters
cntryIf not nil, the null terminated country code is placed in the buffer which must be atleast three characters in size.
prtyIf not nil, the url's priority is placed in the int pointed to by this parameter.
Returns
Pointer to the url. The url is valid until this object is deleted. If no more urls exist, a nil pointer is returned. A subsequent call will start at the front of the list.

Definition at line 221 of file XrdOucFileInfo.cc.

222 {
223  XrdOucFIUrl *uP;
224 
225 // Check if we are at the end
226 //
227  if (!fUrlNext) {fUrlNext = fUrl; return 0;}
228 
229 // Skip to next url for subsequent call
230 //
231  uP = fUrlNext; fUrlNext = fUrlNext->next;
232 
233 // Return country code if wanted
234 //
235  if (cntry) strcpy(cntry, uP->fCC);
236 
237 // Return priority if wanted
238 //
239  if (prty) *prty = uP->fPrty;
240 
241 // Return the url
242 //
243  return uP->fUrl;
244 }

References XrdOucFIUrl::fCC, XrdOucFIUrl::fPrty, XrdOucFIUrl::fUrl, and XrdOucFIUrl::next.

◆ HasProtocol()

bool XrdOucFileInfo::HasProtocol ( const char *  protname)

Check if protocol is in he list of protocols. This does not indicate that an actual url for the protocol was added to this object.

Parameters
protnamePoiner to protocol name ending with a colon
Returns
true if the protocol was encountered and false otherwise.

Definition at line 250 of file XrdOucFileInfo.cc.

251 {
252  return (protList.find(protname) != std::string::npos);
253 }

◆ SetSize()

void XrdOucFileInfo::SetSize ( long long  fsz)
inline

Set file size.

Parameters
fszSupposed size of the file.

Definition at line 170 of file XrdOucFileInfo.hh.

170 {fSize = fsz;}

Member Data Documentation

◆ nextFile

XrdOucFileInfo* XrdOucFileInfo::nextFile

Link field to simply miltiple file processing.

Definition at line 195 of file XrdOucFileInfo.hh.

Referenced by XrdXmlMetaLink::Convert(), and XrdXmlMetaLink::ConvertAll().


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