c++判断是否为目录的示例分享

复制代码 代码如下:

#include<sys/stat.h>
#include<unistd.h>
int is_dir(char *path){
  struct stat buf;
  if(lstat(path , &buf) < 0){
    return FALSE;
  }
  int ret = __S_IFDIR & buf.st_mode;
  if(ret){
    return TRUE;
  }
  return FALSE;
}