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

#include <XrdPosixDir.hh>

+ Inheritance diagram for XrdPosixDir:
+ Collaboration diagram for XrdPosixDir:

Public Member Functions

 XrdPosixDir (const char *path)
 
 ~XrdPosixDir ()
 
long getEntries ()
 
long getOffset ()
 
dirent64 * nextEntry (dirent64 *dp=0)
 
DIR * Open ()
 
void rewind ()
 
void setOffset (long offset)
 
int Status ()
 
bool Unread ()
 
virtual bool Who (XrdPosixDir **dirP)
 
bool Who (XrdPosixDir **dirP)
 
virtual bool Who (XrdPosixFile **fileP)
 
- Public Member Functions inherited from XrdPosixObject
 XrdPosixObject ()
 
virtual ~XrdPosixObject ()
 
bool AssignFD (bool isStream=false)
 
int FDNum ()
 
XrdOucECMsggetECMsg ()
 
void Lock (bool wr=true)
 
void Ref ()
 
int Refs ()
 
void UnLock ()
 
void unRef ()
 
virtual bool Who (XrdPosixDir **dirP)
 
virtual bool Who (XrdPosixFile **fileP)
 

Static Public Member Functions

static int dirNo (DIR *dirP)
 
- Static Public Member Functions inherited from XrdPosixObject
static bool CanStream ()
 
static XrdPosixDirDir (int fildes, bool glk=false)
 
static XrdPosixFileFile (int fildes, bool glk=false)
 
static int Init (int numfd)
 
static void Release (XrdPosixObject *oP, bool needlk=true)
 
static XrdPosixDirReleaseDir (int fildes)
 
static XrdPosixFileReleaseFile (int fildes)
 
static void Shutdown ()
 
static bool Valid (int fd)
 

Static Public Attributes

static const size_t maxDlen = 256
 

Additional Inherited Members

- Public Attributes inherited from XrdPosixObject
XrdOucECMsg ecMsg
 
- Protected Attributes inherited from XrdPosixObject
int fdNum
 
XrdSysRWLock objMutex
 
int refCnt
 
XrdSysRecMutex updMutex
 

Detailed Description

Definition at line 48 of file XrdPosixDir.hh.

Constructor & Destructor Documentation

◆ XrdPosixDir()

XrdPosixDir::XrdPosixDir ( const char *  path)
inline

Definition at line 51 of file XrdPosixDir.hh.

52 : DAdmin(path,ecMsg), myDirVec(0), myDirEnt(0),
53 nxtEnt(0), numEnt(0), eNum(0)
54 {}
XrdOucECMsg ecMsg

◆ ~XrdPosixDir()

XrdPosixDir::~XrdPosixDir ( )
inline

Definition at line 56 of file XrdPosixDir.hh.

56 {delete myDirVec;
57 if (myDirEnt) free(myDirEnt);
58 }

Member Function Documentation

◆ dirNo()

static int XrdPosixDir::dirNo ( DIR *  dirP)
inlinestatic

Definition at line 60 of file XrdPosixDir.hh.

60{return *(int *)dirP;}

Referenced by XrdPosixXrootd::Closedir(), XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::QueryError(), XrdPosixXrootd::Readdir64(), XrdPosixXrootd::Readdir64_r(), XrdPosixXrootd::Rewinddir(), XrdPosixXrootd::Seekdir(), and XrdPosixXrootd::Telldir().

+ Here is the caller graph for this function:

◆ getEntries()

long XrdPosixDir::getEntries ( )
inline

Definition at line 62 of file XrdPosixDir.hh.

62{ return numEnt;}

Referenced by XrdPosixXrootd::Seekdir().

+ Here is the caller graph for this function:

◆ getOffset()

long XrdPosixDir::getOffset ( )
inline

Definition at line 64 of file XrdPosixDir.hh.

64{ return nxtEnt; }

Referenced by XrdPosixXrootd::Telldir().

+ Here is the caller graph for this function:

◆ nextEntry()

dirent64 * XrdPosixDir::nextEntry ( dirent64 *  dp = 0)

Definition at line 48 of file XrdPosixDir.cc.

49{
51 const char *d_name;
52 const int dirhdrln = dp->d_name - (char *)dp;
53 size_t d_nlen;
54
55// Reread the directory if we need to (rewind forces this)
56//
57 if (!myDirVec && !Open()) {eNum = errno; return 0;} // Open() sets ecMsg
58
59// Check if dir is empty or all entries have been read
60//
61 if (nxtEnt >= numEnt) {eNum = 0; return 0;}
62
63// Get information about the next entry
64//
65 dirEnt = myDirVec->At(nxtEnt);
66 d_name = dirEnt->GetName().c_str();
67 d_nlen = dirEnt->GetName().length();
68
69// Create a directory entry
70//
71 if (!dp) dp = myDirEnt;
72 if (d_nlen > maxDlen) d_nlen = maxDlen;
73#ifndef __solaris__
74 dp->d_type = DT_DIR;
75#endif
76#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
77 dp->d_fileno = nxtEnt;
78 dp->d_namlen = d_nlen;
79#else
80 dp->d_ino = nxtEnt+1;
81 dp->d_off = nxtEnt;
82#endif
83 dp->d_reclen = d_nlen + dirhdrln;
84 strncpy(dp->d_name, d_name, d_nlen);
85 dp->d_name[d_nlen] = '\0';
86 nxtEnt++;
87 return dp;
88}
const std::string & GetName() const
Get file name.
ListEntry * At(uint32_t index)
Get an entry at given index.
DIR * Open()
static const size_t maxDlen

References XrdCl::DirectoryList::At(), XrdCl::DirectoryList::ListEntry::GetName(), maxDlen, and Open().

Referenced by XrdPosixXrootd::Readdir64(), and XrdPosixXrootd::Readdir64_r().

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

◆ Open()

DIR * XrdPosixDir::Open ( )

Definition at line 94 of file XrdPosixDir.cc.

95{
96 static const size_t dEntSize = sizeof(dirent64) + maxDlen + 1;
97 int rc;
98
99// Allocate a local dirent. Note that we get additional padding because on
100// some system the dirent structure does not include the name buffer
101//
102 if (!myDirEnt && !(myDirEnt = (dirent64 *)malloc(dEntSize)))
103 {ecMsg.SetErrno(ENOMEM);
104 return (DIR*)0;
105 }
106
107// Get the directory list
108//
111 myDirVec, (uint16_t)0),ecMsg);
112
113// If we failed, return a zero pointer ote that Result() set errno for us
114//
115 if (rc) return (DIR *)0;
116
117// Finish up
118//
119 numEnt = myDirVec->GetSize();
120 return (DIR *)&fdNum;
121}
uint32_t GetSize() const
Get the size of the listing.
XRootDStatus DirList(const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
std::string GetPathWithParams() const
Get the path with params.
Definition XrdClURL.cc:311
int SetErrno(int ecc, int retval=-1, const char *alt=0)
XrdCl::FileSystem Xrd
XrdCl::URL Url
static int Result(const XrdCl::XRootDStatus &Status, XrdOucECMsg &ecMsg, bool retneg1=false)
XrdCl::DirListFlags::Flags dlFlag

References XrdCl::FileSystem::DirList(), XrdPosixGlobals::dlFlag, XrdPosixObject::ecMsg, XrdPosixObject::fdNum, XrdCl::URL::GetPathWithParams(), XrdCl::DirectoryList::GetSize(), maxDlen, XrdPosixMap::Result(), XrdOucECMsg::SetErrno(), XrdPosixAdmin::Url, and XrdPosixAdmin::Xrd.

Referenced by nextEntry(), XrdPosixXrootd::Opendir(), and XrdPosixXrootd::Seekdir().

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

◆ rewind()

void XrdPosixDir::rewind ( )
inline

Definition at line 72 of file XrdPosixDir.hh.

73 nxtEnt = 0; delete myDirVec; myDirVec = 0;
75 }
XrdSysRWLock objMutex

References XrdPosixObject::objMutex, XrdSysRWLock::UnLock(), and XrdSysRWLock::WriteLock().

Referenced by XrdPosixXrootd::Rewinddir().

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

◆ setOffset()

void XrdPosixDir::setOffset ( long  offset)
inline

Definition at line 66 of file XrdPosixDir.hh.

66{ nxtEnt = offset; }

Referenced by XrdPosixXrootd::Seekdir().

+ Here is the caller graph for this function:

◆ Status()

int XrdPosixDir::Status ( )
inline

Definition at line 76 of file XrdPosixDir.hh.

76{return eNum;}

Referenced by XrdPosixXrootd::Readdir64(), and XrdPosixXrootd::Readdir64_r().

+ Here is the caller graph for this function:

◆ Unread()

bool XrdPosixDir::Unread ( )
inline

Definition at line 78 of file XrdPosixDir.hh.

78{return myDirVec == 0;}

Referenced by XrdPosixXrootd::Seekdir().

+ Here is the caller graph for this function:

◆ Who() [1/3]

virtual bool XrdPosixObject::Who ( XrdPosixDir **  dirP)
inlinevirtual

Reimplemented from XrdPosixObject.

Definition at line 89 of file XrdPosixObject.hh.

89{return false;}

◆ Who() [2/3]

bool XrdPosixDir::Who ( XrdPosixDir **  dirP)
inlinevirtual

Reimplemented from XrdPosixObject.

Definition at line 82 of file XrdPosixDir.hh.

82{*dirP = this; return true;}

◆ Who() [3/3]

virtual bool XrdPosixObject::Who ( XrdPosixFile **  fileP)
inlinevirtual

Reimplemented from XrdPosixObject.

Definition at line 91 of file XrdPosixObject.hh.

91{return false;}

Member Data Documentation

◆ maxDlen

const size_t XrdPosixDir::maxDlen = 256
static

Definition at line 84 of file XrdPosixDir.hh.

Referenced by nextEntry(), and Open().


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