xrootd
Loading...
Searching...
No Matches
XrdPosixDir.hh
Go to the documentation of this file.
1#ifndef __XRDPOSIXDIR_H__
2#define __XRDPOSIXDIR_H__
3/******************************************************************************/
4/* */
5/* X r d P o s i x D i r . h h */
6/* */
7/* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/* Modified by Frank Winklmeier to add the full Posix file system definition. */
32/******************************************************************************/
33
34#include <dirent.h>
35
36#if defined(__APPLE__) || defined(__FreeBSD__)
37#if !defined(dirent64)
38#define dirent64 dirent
39#endif
40#endif
41
42#include <unistd.h>
43#include <sys/types.h>
44
47
49{
50public:
51 XrdPosixDir(const char *path)
52 : DAdmin(path), myDirVec(0), myDirEnt(0),
53 nxtEnt(0), numEnt(0), eNum(0)
54 {}
55
57 if (myDirEnt) free(myDirEnt);
58 }
59
60static int dirNo(DIR *dirP) {return *(int *)dirP;}
61
62 long getEntries() { return numEnt;}
63
64 long getOffset() { return nxtEnt; }
65
66 void setOffset(long offset) { nxtEnt = offset; }
67
68 dirent64 *nextEntry(dirent64 *dp=0);
69
70 DIR *Open();
71
73 nxtEnt = 0; delete myDirVec; myDirVec = 0;
75 }
76 int Status() {return eNum;}
77
78 bool Unread() {return myDirVec == 0;}
79
81
82 bool Who(XrdPosixDir **dirP) {*dirP = this; return true;}
83
84static const size_t maxDlen = 256;
85
86private:
89 dirent64 *myDirEnt;
90 uint32_t nxtEnt;
91 uint32_t numEnt;
92 int eNum;
93};
94#endif
Directory list.
Definition XrdClXRootDResponses.hh:650
Definition XrdPosixAdmin.hh:47
Definition XrdPosixDir.hh:49
XrdPosixDir(const char *path)
Definition XrdPosixDir.hh:51
static int dirNo(DIR *dirP)
Definition XrdPosixDir.hh:60
void rewind()
Definition XrdPosixDir.hh:72
dirent64 * myDirEnt
Definition XrdPosixDir.hh:89
int eNum
Definition XrdPosixDir.hh:92
long getOffset()
Definition XrdPosixDir.hh:64
uint32_t nxtEnt
Definition XrdPosixDir.hh:90
XrdPosixAdmin DAdmin
Definition XrdPosixDir.hh:87
DIR * Open()
bool Unread()
Definition XrdPosixDir.hh:78
XrdCl::DirectoryList * myDirVec
Definition XrdPosixDir.hh:88
dirent64 * nextEntry(dirent64 *dp=0)
uint32_t numEnt
Definition XrdPosixDir.hh:91
void setOffset(long offset)
Definition XrdPosixDir.hh:66
int Status()
Definition XrdPosixDir.hh:76
~XrdPosixDir()
Definition XrdPosixDir.hh:56
long getEntries()
Definition XrdPosixDir.hh:62
static const size_t maxDlen
Definition XrdPosixDir.hh:84
bool Who(XrdPosixDir **dirP)
Definition XrdPosixDir.hh:82
Definition XrdPosixObject.hh:42
XrdSysRWLock objMutex
Definition XrdPosixObject.hh:95
virtual bool Who(XrdPosixDir **dirP)
Definition XrdPosixObject.hh:86
void WriteLock()
Definition XrdSysPthread.hh:343
void UnLock()
Definition XrdSysPthread.hh:348