utils.c
// Strip the filename component from a path
Strip the filename component from a path
Strip the filename component from a path
char *base_path(char *path) {
    int end = strlen(path) - 1;
    char *result = malloc(strlen(path) + 1);
    while (end >= 0 && path[end] != '/') end--;
    if (end >= 0) result = memcpy(result, path, end + 1);
    result[end + 1] = 0;
    return result;
}
char * base_path ( char * path ) { int end = strlen ( path ) - 1 ; char * result = malloc ( strlen ( path ) + 1 ) ; while ( end >= 0 && path [ end ] != ' ' ) end -- ; if ( end >= 0 ) result = memcpy ( result , path , end + 1 ) ; result [ end + 1 ] = 0 ; return result ; }
Strip the filename component from a path
Strip the filename component from a path