utils/files.c
int create_directory(char* dir)
{
    /* Used variables */
    char tmp[256];
    char *p = NULL;
    size_t len;

    /* Parse directory from path */
    snprintf(tmp, sizeof(tmp),"%s",dir);
    len = strlen(tmp);
    if(tmp[len - 1] == '/') tmp[len - 1] = 0;

    /* Start creation recursively */
    for(p = tmp + 1; *p; p++)
    {
        if(*p == '/')
        {
            *p = 0;
            if (!path_exists(tmp))
            {
                if (mkdir(tmp, 0777) < 0)
                    return 0;
            }

            *p = '/';
        }
    }

    /* Create final directory */
    if (!path_exists(tmp))
    {
        if (mkdir(tmp, 0777) < 0)
            return 0;
    }

    return 1;
}
/*
 * create_directory - Recursively create directory. Argument dir is
 * directory path. Function checks directory path and if directory
 * doesnot exsists, function creates it. On success return value is
 * 1, otherwise function returns 0 if there is something wrong.
 */
Recursively create directory. Argument dir is
directory path. Function checks directory path and if directory
doesnot exsists, function creates it. On success return value is
1, otherwise function returns 0 if there is something wrong.
Recursively create directory . Argument dir is directory path . Function checks directory path and if directory doesnot exsists function creates it . On success return value is 1 otherwise function returns 0 if there is something wrong .
int create_directory(char* dir)
{
    char tmp[256];
    char *p = NULL;
    size_t len;
    snprintf(tmp, sizeof(tmp),"%s",dir);
    len = strlen(tmp);
    if(tmp[len - 1] == '/') tmp[len - 1] = 0;
    for(p = tmp + 1; *p; p++)
    {
        if(*p == '/')
        {
            *p = 0;
            if (!path_exists(tmp))
            {
                if (mkdir(tmp, 0777) < 0)
                    return 0;
            }
            *p = '/';
        }
    }
    if (!path_exists(tmp))
    {
        if (mkdir(tmp, 0777) < 0)
            return 0;
    }
    return 1;
}
int create_directory ( char * dir ) { char tmp [ 256 ] ; char * p = NULL ; size_t len ; snprintf ( tmp , sizeof ( tmp ) , " " , dir ) ; len = strlen ( tmp ) ; if ( tmp [ len - 1 ] == ' ' ) tmp [ len - 1 ] = 0 ; for ( p = tmp + 1 ; * p ; p ++ ) { if ( * p == ' ' ) { * p = 0 ; if ( ! path_exists ( tmp ) ) { if ( mkdir ( tmp , 0777 ) < 0 ) return 0 ; } * p = ' ' ; } } if ( ! path_exists ( tmp ) ) { if ( mkdir ( tmp , 0777 ) < 0 ) return 0 ; } return 1 ; }
create_directory - Recursively create directory.
create_directory - Recursively create directory .
/* Used variables */ /* Parse directory from path */ /* Start creation recursively */ /* Create final directory */