#include <XrdSysDir.hh>
Definition at line 48 of file XrdSysDir.hh.
◆ XrdSysDir()
XrdSysDir::XrdSysDir |
( |
const char * | path | ) |
|
Definition at line 51 of file XrdSysDir.cc.
52{
53
54
55
56
57 lasterr = 0; dhandle = 0;
58 if (path && strlen(path) > 0) {
59#if !defined(WINDOWS)
60 dhandle = (
void *)
opendir(path);
61 if (!dhandle)
62 lasterr = errno;
63#else
64 WIN32_FIND_DATA filedata;
65 dhandle = (void *) ::FindFirstFile(path, &filedata);
66 if ((HANDLE)dhandle == INVALID_HANDLE_VALUE) {
67 lasterr = EINVAL;
68 dhandle = 0;
69 }
70 else if (!(filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
71 lasterr = ENOTDIR;
72 dhandle = 0;
73 }
74#endif
75 } else
76
77 lasterr = EINVAL;
78}
References opendir.
◆ ~XrdSysDir()
XrdSysDir::~XrdSysDir |
( |
| ) |
|
|
virtual |
Definition at line 81 of file XrdSysDir.cc.
82{
83
84
85 if (dhandle) {
86#if !defined(WINDOWS)
88#else
89 ::FindClose((HANDLE)dhandle);
90#endif
91 }
92}
References closedir.
◆ isValid()
bool XrdSysDir::isValid |
( |
| ) |
|
|
inline |
Definition at line 54 of file XrdSysDir.hh.
54{ return (dhandle ? 1 : 0); }
◆ lastError()
int XrdSysDir::lastError |
( |
| ) |
|
|
inline |
◆ nextEntry()
char * XrdSysDir::nextEntry |
( |
| ) |
|
Definition at line 95 of file XrdSysDir.cc.
96{
97
98
99
100
101 char *dent = 0;
102
103 lasterr = 0;
104 if (!dhandle) {
105 lasterr = EINVAL;
106 return dent;
107 }
108
109#if !defined(WINDOWS)
110 struct dirent *ent =
readdir((DIR *)dhandle);
111 if (!ent) {
112 if (errno == EBADF)
113 lasterr = errno;
114 } else {
115 dent = (char *) ent->d_name;
116 }
117#else
118 WIN32_FIND_DATA filedata;
119 if (::FindNextFile((HANDLE)dhandle, &filedata)) {
120 dent = (char *) filedata.cFileName;
121 } else {
122 if (::GetLastError() != ERROR_NO_MORE_FILES)
123 lasterr = EBADF;
124 }
125#endif
126
127 return dent;
128}
References readdir.
The documentation for this class was generated from the following files: