/* This file is part of Lcrzo.
*/

int lcrzo_priv_stat_type(struct stat st, 
			 lcrzo_int16 *ptype)
{
  /*set the correct value*/
  if (ptype!=NULL)
  { 
#if defined LCRZODEF_SYSTEM_Unix
    if (S_ISREG(st.st_mode)) *ptype=LCRZO_FILE_TYPE_REG;
    else if (S_ISDIR(st.st_mode)) *ptype=LCRZO_FILE_TYPE_DIR;
    else if (S_ISLNK(st.st_mode)) *ptype=LCRZO_FILE_TYPE_LINK;
    else if (S_ISSOCK(st.st_mode)) *ptype=LCRZO_FILE_TYPE_SOCK;
#elif defined LCRZODEF_SYSTEM_Windows
    if (st.st_mode & _S_IFREG) *ptype=LCRZO_FILE_TYPE_REG;
    else if (st.st_mode & _S_IFDIR) *ptype=LCRZO_FILE_TYPE_DIR;
#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif
    else *ptype=LCRZO_FILE_TYPE_OTHER;
  }
  return(LCRZO_ERR_OK);
}

