Determine if a file exists at the supplied pathname.

Return TypeFunction nameArguments
hzEcodeTestFile(const char*,)

Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp

Function Logic:

0:START 1:unknown 2:errno 3:EACCES 4:rc

Function body:

hzEcode TestFile (const char* fullpath)
{
   //  Category: Directory
   //  
   //  Determine if a file exists at the supplied pathname.
   //  
   //  Arguments: 1) fullpath The full pathname of the anticipated file
   //  
   //  Returns: E_ARGUMENT If the pathname was not supplied
   //     E_NODATA If permissions were denied
   //     E_CORRUPT If the supplied pathname was nonsensical (stat operation produced an errno of EIO, ELOOP or EOVERFLOW)
   //     E_OVERFLOW If the supplied pathname was too long
   //     E_NOTFOUND If the anticipated file does not exist
   //     E_TYPE  If the supplied pathname is that of a directory or non-file
   //     E_OK  If the files exists
   FSTAT   fs ;            //  File status
   hzEcode rc = E_OK ;     //  Return code
   if (lstat(fullpath, &fs) == -1)
   {
       switch  (errno)
       {
       case EACCES:        rc = E_NODATA ;     break ;
       case EIO:           rc = E_CORRUPT ;    break ;
       case ELOOP:         rc = E_CORRUPT ;    break ;
       case ENAMETOOLONG:  rc = E_OVERFLOW ;   break ;
       case ENOENT:        rc = E_NOTFOUND ;   break ;
       case ENOTDIR:       rc = E_TYPE ;       break ;
       case EOVERFLOW:     rc = E_CORRUPT ;    break ;
       }
   }
   else
   {
       if (ISDIR(fs.st_mode))
           rc = E_TYPE ;
   }
   return rc ;
}