Determine if a directory exists at the supplied pathname.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | DirExists | (const char*,) |
Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp
Function Logic:
Function body:
hzEcode DirExists (const char* dirname)
{
// Category: Directory
//
// Determine if a directory exists at the supplied pathname.
//
// Arguments: 1) dirname The full pathname of the anticipated file
//
// Returns: E_ARGUMENT If the pathname was not supplied
// E_NOTFOUND If the directory does not exist
// E_TYPE If the supplied pathname is not that of a directory
// E_OK If the directory exists
FSTAT fs ; // Directory status
if (!dirname || !dirname[0])
return E_ARGUMENT ;
if (stat(dirname, &fs) == -1)
return E_NOTFOUND ;
if (!S_ISDIR(fs.st_mode))
return E_TYPE ;
return E_OK ;
}