vlc_linux/vlc-3.0.16/modules/gui/skins2/src/theme_loader.cpp
/* Recursive make directory
 * Abort if you get an ENOENT errno somewhere in the middle
 * e.g. ignore error "mkdir on existing directory"
 *
 * return 1 if OK, 0 on error
 */
Recursive make directory
Abort if you get an ENOENT errno somewhere in the middle
e.g. ignore error "mkdir on existing directory"

return 1 if OK, 0 on error
Recursive make directory Abort if you get an ENOENT errno somewhere in the middle e . g . ignore error " mkdir on existing directory " return 1 if OK 0 on error
static int makedir( const char *newdir )
{
    char *p, *buffer = strdup( newdir );
    int  len = strlen( buffer );
    if( len <= 0 )
    {
        free( buffer );
        return 0;
    }
    if( buffer[len-1] == '/' )
    {
        buffer[len-1] = '\0';
    }
    if( vlc_mkdir( buffer, 0775 ) == 0 )
    {
        free( buffer );
        return 1;
    }
    p = buffer + 1;
    while( 1 )
    {
        char hold;
        while( *p && *p != '\\' && *p != '/' ) p++;
        hold = *p;
        *p = 0;
        if( ( vlc_mkdir( buffer, 0775 ) == -1 ) && ( errno == ENOENT ) )
        {
            fprintf( stderr, "couldn't create directory %s\n", buffer );
            free( buffer );
            return 0;
        }
        if( hold == 0 ) break;
        *p++ = hold;
    }
    free( buffer );
    return 1;
}
static int makedir ( const char * newdir ) { char * p , * buffer = strdup ( newdir ) ; int len = strlen ( buffer ) ; if ( len <= 0 ) { free ( buffer ) ; return 0 ; } if ( buffer [ len - 1 ] == ' ' ) { buffer [ len - 1 ] = ' \0 ' ; } if ( vlc_mkdir ( buffer , 0775 ) == 0 ) { free ( buffer ) ; return 1 ; } p = buffer + 1 ; while ( 1 ) { char hold ; while ( * p && * p != ' \\ ' && * p != ' ' ) p ++ ; hold = * p ; * p = 0 ; if ( ( vlc_mkdir ( buffer , 0775 ) == -1 ) && ( errno == ENOENT ) ) { fprintf ( stderr , " \n " , buffer ) ; free ( buffer ) ; return 0 ; } if ( hold == 0 ) break ; * p ++ = hold ; } free ( buffer ) ; return 1 ; }
Recursive make directory
 Abort if you get an ENOENT errno somewhere in the middle
 e.g.
Recursive make directory Abort if you get an ENOENT errno somewhere in the middle e . g .