XRootD
XrdSfsNativeDirectory Class Reference

#include <XrdSfsNative.hh>

+ Inheritance diagram for XrdSfsNativeDirectory:
+ Collaboration diagram for XrdSfsNativeDirectory:

Public Member Functions

 XrdSfsNativeDirectory (char *user=0, int monid=0)
 
 ~XrdSfsNativeDirectory ()
 
int close ()
 
const char * FName ()
 
const char * nextEntry ()
 
int open (const char *dirName, const XrdSecClientName *client=0, const char *opaque=0)
 
- Public Member Functions inherited from XrdSfsDirectory
 XrdSfsDirectory (const char *user=0, int MonID=0)
 
 XrdSfsDirectory (XrdOucErrInfo &eInfo)
 
 XrdSfsDirectory (XrdSfsDirectory &wrapD)
 
virtual ~XrdSfsDirectory ()
 Destructor. More...
 
virtual int autoStat (struct stat *buf)
 
virtual int open (const char *path, const XrdSecEntity *client=0, const char *opaque=0)=0
 

Additional Inherited Members

- Public Attributes inherited from XrdSfsDirectory
XrdOucErrInfoerror
 

Detailed Description

Definition at line 45 of file XrdSfsNative.hh.

Constructor & Destructor Documentation

◆ XrdSfsNativeDirectory()

XrdSfsNativeDirectory::XrdSfsNativeDirectory ( char *  user = 0,
int  monid = 0 
)
inline

Definition at line 59 of file XrdSfsNative.hh.

60  : XrdSfsDirectory(user, monid)
61  {ateof = 0; fname = 0;
62  dh = (DIR *)0;
63  d_pnt = &dirent_full.d_entry;
64  }
XrdSfsDirectory(const char *user=0, int MonID=0)

◆ ~XrdSfsNativeDirectory()

XrdSfsNativeDirectory::~XrdSfsNativeDirectory ( )
inline

Definition at line 66 of file XrdSfsNative.hh.

66 {if (dh) close();}

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

int XrdSfsNativeDirectory::close ( )
virtual

Close the directory.

Returns
One of SFS_OK or SFS_ERROR

Implements XrdSfsDirectory.

Definition at line 235 of file XrdSfsNative.cc.

243 {
244  static const char *epname = "closedir";
245 
246 // Release the handle
247 //
248  if (dh && closedir(dh))
249  {XrdSfsNative::Emsg(epname, error, errno, "close directory", fname);
250  return SFS_ERROR;
251  }
252 
253 // Do some clean-up
254 //
255  if (fname) free(fname);
256  dh = (DIR *)0;
257  return SFS_OK;
258 }
int closedir(DIR *dirp)
#define SFS_ERROR
#define SFS_OK
XrdOucErrInfo & error
static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, const char *y="")

References closedir(), XrdSfsNative::Emsg(), XrdSfsDirectory::error, SFS_ERROR, and SFS_OK.

Referenced by ~XrdSfsNativeDirectory().

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

◆ FName()

const char* XrdSfsNativeDirectory::FName ( )
inlinevirtual

Get the directory path.

Returns
Null terminated string of the path used in open().

Implements XrdSfsDirectory.

Definition at line 57 of file XrdSfsNative.hh.

57 {return (const char *)fname;}

◆ nextEntry()

const char * XrdSfsNativeDirectory::nextEntry ( )
virtual

Get the next directory entry.

Returns
A null terminated string with the directory name. Normally, "." ".." are not returned. If a null pointer is returned then if this is due to an error, error.code should contain errno. Otherwise, error.code should contain zero to indicate that no more entries exist (i.e. end of list). See autoStat() for additional caveats.

Implements XrdSfsDirectory.

Definition at line 171 of file XrdSfsNative.cc.

182 {
183  static const char *epname = "nextEntry";
184  struct dirent *rp;
185  int retc;
186 
187 // Lock the direcrtory and do any required tracing
188 //
189  if (!dh)
190  {XrdSfsNative::Emsg(epname,error,EBADF,"read directory",fname);
191  return (const char *)0;
192  }
193 
194 // Check if we are at EOF (once there we stay there)
195 //
196  if (ateof) return (const char *)0;
197 
198 // Read the next directory entry
199 //
200 #if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
201  errno = 0;
202  rp = readdir(dh);
203  if (!rp)
204  {if (!(retc = errno)) {ateof = 1; error.clear();}
205  else XrdSfsNative::Emsg(epname,error,retc,"read directory",fname);
206  d_pnt->d_name[0] = '\0';
207  return (const char *)0;
208  }
209  return (const char *)(rp->d_name);
210 #else
211  if ((retc = readdir_r(dh, d_pnt, &rp)))
212  {XrdSfsNative::Emsg(epname,error,retc,"read directory",fname);
213  d_pnt->d_name[0] = '\0';
214  return (const char *)0;
215  }
216 
217 // Check if we have reached end of file
218 //
219  if (!rp || !d_pnt->d_name[0])
220  {ateof = 1;
221  error.clear();
222  return (const char *)0;
223  }
224 
225 // Return the actual entry
226 //
227  return (const char *)(d_pnt->d_name);
228 #endif
229 }
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
struct dirent * readdir(DIR *dirp)
void clear()
Reset data and error information to null. Any appenadges are released.

References XrdOucErrInfo::clear(), XrdSfsNative::Emsg(), XrdSfsDirectory::error, readdir(), and readdir_r().

+ Here is the call graph for this function:

◆ open()

int XrdSfsNativeDirectory::open ( const char *  dirName,
const XrdSecClientName client = 0,
const char *  opaque = 0 
)

Definition at line 131 of file XrdSfsNative.cc.

143 {
144  static const char *epname = "opendir";
145 
146 // Verify that this object is not already associated with an open directory
147 //
148  if (dh) return
149  XrdSfsNative::Emsg(epname, error, EADDRINUSE,
150  "open directory", dir_path);
151 
152 // Set up values for this directory object
153 //
154  ateof = 0;
155  fname = strdup(dir_path);
156 
157 // Open the directory and get it's id
158 //
159  if (!(dh = opendir(dir_path))) return
160  XrdSfsNative::Emsg(epname,error,errno,"open directory",dir_path);
161 
162 // All done
163 //
164  return SFS_OK;
165 }
DIR * opendir(const char *path)

References XrdSfsNative::Emsg(), XrdSfsDirectory::error, opendir(), and SFS_OK.

+ Here is the call graph for this function:

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