Populate a hzString with the name of the current working directory. This function calls the GNU system function get_current_dir_name().
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | GetCurrDir | (hzString&,) |
Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp
Function Logic:
Function body:
hzEcode GetCurrDir (hzString& Dir)
{
// Category: Directory
//
// Populate a hzString with the name of the current working directory. This function calls the GNU system function get_current_dir_name().
//
// Arguments: 1) Dir The hzString reference to populate
//
// Returns: E_NOTFOUND If the current directory has access issues or has been unlinked
// E_OK If the operation was successful
_hzfunc("GetCurrDir") ;
char* cpDir ; // Buffer for current working directory
Dir.Clear() ;
cpDir = get_current_dir_name() ;
if (!cpDir)
{
if (errno == EACCES) return hzwarn(E_NOTFOUND, "The current working directory has access issues") ;
if (errno == ENOENT) return hzwarn(E_NOTFOUND, "The current working directory has been unlinked") ;
return hzwarn(E_NOTFOUND, "Unspecified error") ;
}
Dir = cpDir ;
free(cpDir) ;
return E_OK ;
}