C++ determines whether to share for the directory example

  • 2020-04-02 02:17:07
  • OfStack


#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;
}


Related articles: