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
45
#include "
XrdPosix/XrdPosixAdmin.hh
"
46
#include "
XrdPosix/XrdPosixObject.hh
"
47
48
// Forward declarations
49
struct
stat
;
50
51
class
XrdPosixDir
:
public
XrdPosixObject
52
{
53
public
:
54
XrdPosixDir
(
const
char
*path)
55
: DAdmin(path,
ecMsg
), myDirVec(0), myDirEnt(0),
56
myBuf(nullptr), nxtEnt(0), numEnt(0), eNum(0)
57
{}
58
59
~XrdPosixDir
() {
delete
myDirVec;
60
if
(myDirEnt) free(myDirEnt);
61
}
62
63
static
int
dirNo
(DIR *dirP) {
return
*(
int
*)dirP;}
64
65
long
getEntries
() {
return
numEnt;}
66
67
long
getOffset
() {
return
nxtEnt; }
68
69
void
setOffset
(
long
offset) { nxtEnt = offset; }
70
71
dirent64 *
nextEntry
(dirent64 *dp=0);
72
73
DIR *
Open
();
74
75
// Return the stat info corresponding to the current directory entry
76
// On error, returns -errno; otherwise, returns 0 and stores a pointer
77
// to buf internally
78
int
StatRet
(
struct
stat
*buf);
79
80
void
rewind
() {
objMutex
.
WriteLock
();
81
nxtEnt = 0;
delete
myDirVec; myDirVec = 0;
82
objMutex
.
UnLock
();
83
}
84
int
Status
() {
return
eNum;}
85
86
bool
Unread
() {
return
myDirVec == 0;}
87
88
using
XrdPosixObject::Who
;
89
90
bool
Who
(
XrdPosixDir
**dirP) {*dirP =
this
;
return
true
;}
91
92
static
const
size_t
maxDlen
= 256;
93
94
private
:
95
XrdPosixAdmin
DAdmin;
96
XrdCl::DirectoryList
*myDirVec;
97
dirent64 *myDirEnt;
98
struct
stat
*myBuf;
99
uint32_t nxtEnt;
100
uint32_t numEnt;
101
int
eNum;
102
};
103
#endif
XrdPosixAdmin.hh
XrdPosixObject.hh
stat
#define stat(a, b)
Definition
XrdPosix.hh:101
XrdCl::DirectoryList
Directory list.
Definition
XrdClXRootDResponses.hh:651
XrdPosixAdmin
Definition
XrdPosixAdmin.hh:48
XrdPosixDir
Definition
XrdPosixDir.hh:52
XrdPosixDir::XrdPosixDir
XrdPosixDir(const char *path)
Definition
XrdPosixDir.hh:54
XrdPosixDir::StatRet
int StatRet(struct stat *buf)
Definition
XrdPosixDir.cc:100
XrdPosixDir::dirNo
static int dirNo(DIR *dirP)
Definition
XrdPosixDir.hh:63
XrdPosixDir::rewind
void rewind()
Definition
XrdPosixDir.hh:80
XrdPosixDir::getOffset
long getOffset()
Definition
XrdPosixDir.hh:67
XrdPosixDir::Open
DIR * Open()
Definition
XrdPosixDir.cc:110
XrdPosixDir::Unread
bool Unread()
Definition
XrdPosixDir.hh:86
XrdPosixDir::nextEntry
dirent64 * nextEntry(dirent64 *dp=0)
Definition
XrdPosixDir.cc:48
XrdPosixDir::setOffset
void setOffset(long offset)
Definition
XrdPosixDir.hh:69
XrdPosixDir::Status
int Status()
Definition
XrdPosixDir.hh:84
XrdPosixDir::~XrdPosixDir
~XrdPosixDir()
Definition
XrdPosixDir.hh:59
XrdPosixDir::getEntries
long getEntries()
Definition
XrdPosixDir.hh:65
XrdPosixDir::maxDlen
static const size_t maxDlen
Definition
XrdPosixDir.hh:92
XrdPosixDir::Who
bool Who(XrdPosixDir **dirP)
Definition
XrdPosixDir.hh:90
XrdPosixObject
Definition
XrdPosixObject.hh:43
XrdPosixObject::objMutex
XrdSysRWLock objMutex
Definition
XrdPosixObject.hh:100
XrdPosixObject::Who
virtual bool Who(XrdPosixDir **dirP)
Definition
XrdPosixObject.hh:89
XrdPosixObject::ecMsg
XrdOucECMsg ecMsg
Definition
XrdPosixObject.hh:96
XrdSysRWLock::WriteLock
void WriteLock()
Definition
XrdSysPthread.hh:343
XrdSysRWLock::UnLock
void UnLock()
Definition
XrdSysPthread.hh:348
XrdPosix
XrdPosixDir.hh
Generated by
1.12.0