linux创建目录简单函数

  1. static void linux_create_dir (const char* dirpath)  
  2. {  
  3.  char* p = 0;  
  4.  char sdir[256]={0};  
  5.  snprintf (sdirsizeof(sdir)-1, "%s"dirpath);  
  6.   
  7.  p = strchr (sdir'/');  
  8.  while (p)  
  9.  {  
  10.   *p = '/0';  
  11.   if (*sdir != '/0')  
  12.    mkdir(sdir, 0777);  
  13.   *p = '/';  
  14.   p++;  
  15.   p = strchr (p, '/');  
  16.  }  
  17.   
  18.  if (strrchr(dirpath'.') == NULL)  
  19.   mkdir (dirpath, 0777);  
  20. }  

你可能感兴趣的:(linux创建目录简单函数)