if ((lstat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
if ((stat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
mkdirs(char *path, mode_t mode){    char *cp;    struct stat sb;    int res;        while (*path == '/' && path[1] == '/')	path++;    while ((cp = strrchr(path, '/')) && cp[1] == '\0')	*cp = '\0';    if (cp && cp != path) {	*cp = '\0';	if ((lstat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&	    mkdirs(path, mode) < 0) {	    return -1;	}	*cp = '/';    }    res = mkdir(path, mode);    if ((res != 0) && (errno == EEXIST))	return 0;     else	return res;}