Filename/Get_Fullname [ Functions ]

NAME

Get_Fullname --

SYNOPSIS

char* Get_Fullname( struct RB_Filename *arg_rb_filename )

FUNCTION

Give the full name of the file, that is the name of the file including the extension and the path. The path can be relative or absolute.

NOTE

The string returned is owned by this function so don't change it.

SOURCE

{
    char               *result = arg_rb_filename->fullname;

    if ( result == NULL )
    {
        unsigned int        size = strlen( arg_rb_filename->name ) +
            strlen( arg_rb_filename->path->name ) + 1;
        result = ( char * ) malloc( size * sizeof( char ) );
        assert( result );
        *result = '\0';
        strcat( result, arg_rb_filename->path->name );
        strcat( result, arg_rb_filename->name );
        /* Save the result so it can be reused later on, and we can properly deallocate it. */
        arg_rb_filename->fullname = result;
    }
    return result;
}