Filename
[ Top ] [ ROBODoc ] [ Modules ]
NAME
Functions to deal with keeping track of filenames and directory names.
Get_Fullname
[ Top ] [ Filename ] [ 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; }
RB_Get_Extension
[ Top ] [ Filename ] [ Functions ]
NAME
RB_Get_Extension --
FUNCTION
Give the extension of this file. That is the part after the last '.' if there is any.
SYNOPSIS
char* RB_Get_Extension( struct RB_Filename *arg_rb_filename )
RESULT
pointer to the extension pointer to a '\0' if no extension was found.
NOTE
The string returned is owned by this function so don't change it.
SOURCE
{ char *c = arg_rb_filename->name; int i = strlen( c ); for ( c += i; c != arg_rb_filename->name && ( *c != '.' ); --c ) { /* Empty */ } if ( *c == '.' ) { ++c; } else { c = arg_rb_filename->name; c += i; } return c; }
RB_Get_Filename
[ Top ] [ Filename ] [ Functions ]
NAME
RB_Get_Filename --
FUNCTION
Give the name of this file. That is the name of the file without its path but with the extension.
SYNOPSIS
char* RB_Get_Filename( struct RB_Filename *arg_rb_filename )
RESULT
pointer to the extension pointer to a '\0' if no extension was found.
NOTE
The string returned is owned by this function so don't change it.
RB_Get_Path
[ Top ] [ Filename ] [ Functions ]
SYNOPSIS
char* RB_Get_Path( struct RB_Filename *arg_rb_filename )
FUNCTION
Give the path for this file.
NOTE
The string returned is owned by this function so don't change it.
RB_Get_RB_Filename
[ Top ] [ Filename ] [ Functions ]
NAME
RB_Get_RB_Filename
SYNOPSIS
struct RB_Filename* RB_Get_RB_Filename( char *arg_filename, struct RB_Path *arg_rb_path )
INPUTS
- arg_rb_filename --
- arg_rb_path --
FUNCTION
Create a new RB_Filename structure based on arg_filename and arg_rb_path.
SOURCE
{ struct RB_Filename *rb_filename = ( struct RB_Filename * ) malloc( sizeof( struct RB_Filename ) ); rb_filename->name = ( char * ) malloc( strlen( arg_filename ) + 1 ); rb_filename->docname = 0; rb_filename->fullname = 0; rb_filename->fulldocname = 0; strcpy( rb_filename->name, arg_filename ); rb_filename->path = arg_rb_path; return rb_filename; }