[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] Path delimiter characters
From: |
Detlef Würkner |
Subject: |
[Devel] Path delimiter characters |
Date: |
Sun, 08 Aug 2004 14:19:34 +0200 |
Hello!
In src/base/ftrfork.c there exists this function
----8<----
static char*
raccess_make_file_name( FT_Memory memory,
const char *original_name,
const char *insertion )
{
char* new_name;
char* tmp;
const char* slash;
unsigned new_length;
FT_ULong error;
new_length = ft_strlen( original_name ) + ft_strlen( insertion );
if ( FT_ALLOC( new_name, new_length + 1 ) )
return NULL;
tmp = ft_strrchr( original_name, '/' );
if ( !tmp )
tmp = ft_strrchr( original_name, ':' );
if ( tmp )
{
ft_strncpy( new_name, original_name, tmp - original_name + 1 );
new_name[tmp - original_name + 1] = '\0';
slash = tmp + 1;
}
else
{
slash = original_name;
new_name[0] = '\0';
}
ft_strcat( new_name, insertion );
ft_strcat( new_name, slash );
return new_name;
}
----8<----
which assumes that the only valid path delimiter character is '/'.
This may not work on MS-DOS and other systems that do also accept
a backslash as path delimiter. And it does not work on AmigaOS which
uses the ':' character to separate a volume name from the rest of a path,
e.g. VolumeName:FontName.otf is a valid path there (which would be
expressed as /DeviceName/FontName.otf in Unix). A quick fix for AmigaOS
is using something like
tmp = ft_strrchr( original_name, '/' );
if ( !tmp )
tmp = ft_strrchr( original_name, ':' );
which is guaranteed to work because there is only upto one ':' allowed in
a path and no '/' is allowed to appear to the left of a ':'. However,
that could break other systems where ':' is a normal character that may
appear in a path, so some #ifdef should be used. What about
tmp = ft_strrchr( original_name, '/' );
#ifdef SECOND_PATH_DELIMITER
if ( !tmp )
tmp = ft_strrchr( original_name, SECOND_PATH_DELIMITER );
#endif
in ftrfork.c and something like
/*************************************************************************/
/* */
/* Define an additional path delimiter besides the '/' character here if */
/* your operating system uses this, e.g. ':' for AmigaOS. */
/* */
/* #define SECOND_PATH_DELIMITER ':' */
in include/freetype/config/ftoption.h ?
Ciao, Detlef
--
_ // address@hidden
\X/ Detlef Wuerkner, Langgoens/Germany
- [Devel] Path delimiter characters,
Detlef Würkner <=