C语言检测对象是文件还是文件夹
bool file_exists  
  (  
    const char * Pathname  
  )  
  /* is there a regular file by the name of Pathname. */  
  {  
    bool Exists;  
    struct stat Info;  
     if (stat(Pathname, &Info) == 0)  
      {  
        Exists = S_ISREG(Info.st_mode);  
      }  
    else  
      {  
        Exists = false;  
      } /*if*/  
    return  
        Exists;  
  } /*file_exists*/  
检测是否是文件夹
bool directory_exists  
  (  
    const char * Pathname,  
    bool FollowSymlink  
      /* true to return true if Pathname is a symlink to a directory, 
        false to return false for a symlink */  
  )  
  /* is there a directory by the name of Pathname. */  
  {  
    bool Exists;  
    struct stat Info;  
    if  
      (  
            (FollowSymlink ?  
                stat(Pathname, &Info)  
            :  
                lstat(Pathname, &Info)  
            )  
        ==  
            0  
      )  
      {  
        Exists = S_ISDIR(Info.st_mode);  
      }  
    else  
      {  
        Exists = false;  
      } /*if*/  
    return  
        Exists;  
  } /*directory_exists*/  
