Loading...
Searching...
No Matches
XrdSysDir Class Reference

`#include <XrdSysDir.hh>`

Collaboration diagram for XrdSysDir:

## Public Member Functions

| XrdSysDir (const char *path)
virtual | ~XrdSysDir ()
bool | isValid ()
int | lastError ()
char * | nextEntry ()

## Detailed Description

Definition at line 48 of file XrdSysDir.hh.

## Constructor & Destructor Documentation

## XrdSysDir()

XrdSysDir::XrdSysDir | ( | const char * | path | ) |

Definition at line 51 of file XrdSysDir.cc.

{
// Constructor. Initialize a directory handle for 'path'.
// Use isValid() to check the result of this operation, and lastError()
// to get the last error code, if any.
lasterr = 0; dhandle = 0;
if (path && strlen(path) > 0) {
#if !defined(WINDOWS)
dhandle = (void *) opendir(path);
if (!dhandle)
lasterr = errno;
#else
WIN32_FIND_DATA filedata;
dhandle = (void *) ::FindFirstFile(path, &filedata);
if ((HANDLE)dhandle == INVALID_HANDLE_VALUE) {
lasterr = EINVAL;
dhandle = 0;
}
else if (!(filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
lasterr = ENOTDIR;
dhandle = 0;
}
#endif
} else
// Invalid argument
lasterr = EINVAL;
}
opendir
#define opendir(a)
Definition XrdPosix.hh:78

References opendir.

## ~XrdSysDir()

XrdSysDir::~XrdSysDir | ( |  | ) |

virtual

Definition at line 81 of file XrdSysDir.cc.

{
// Destructor.
if (dhandle) {
#if !defined(WINDOWS)
closedir((DIR *)dhandle);
#else
::FindClose((HANDLE)dhandle);
#endif
}
}
closedir
#define closedir(a)
Definition XrdPosix.hh:50

References closedir.

## Member Function Documentation

## isValid()

bool XrdSysDir::isValid | ( |  | ) |

inline

Definition at line 54 of file XrdSysDir.hh.

{ return (dhandle ? 1 : 0); }

## lastError()

int XrdSysDir::lastError | ( |  | ) |

inline

Definition at line 55 of file XrdSysDir.hh.

{ return lasterr; }

## nextEntry()

char * XrdSysDir::nextEntry | ( |  | ) |

Definition at line 95 of file XrdSysDir.cc.

{
// Get next entry in directory structure.
// Return 0 if no more entries or error. In the latter case
// the error code can be retrieved via lastError().
char *dent = 0;
lasterr = 0;
if (!dhandle) {
lasterr = EINVAL;
return dent;
}
#if !defined(WINDOWS)
struct dirent *ent = readdir((DIR *)dhandle);
if (!ent) {
if (errno == EBADF)
lasterr = errno;
} else {
dent = (char *) ent->d_name;
}
#else
WIN32_FIND_DATA filedata;
if (::FindNextFile((HANDLE)dhandle, &filedata)) {
dent = (char *) filedata.cFileName;
} else {
if (::GetLastError() != ERROR_NO_MORE_FILES)
lasterr = EBADF;
}
#endif
// Done
return dent;
}
readdir
#define readdir(a)
Definition XrdPosix.hh:86

References readdir.

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

- XrdSysDir.hh
- XrdSysDir.cc