Re: g_build_path/filename



On 8 Sep 2001, Owen Taylor wrote:

> The following patch adds what I think is a pretty
> important function we missed: 
>  
>  gchar *g_build_filename (const gchar *first_element, ...);
> 
> And as a "free" side effect of implementation:
> 
>  gchar *g_build_path (const gchar *separator, ...);
> 
> Which is not as important but fairly useful.
> 
> The reasons for adding g_build_filename() are:
> 
>  - It gets used a lot (there are ~10 places in GTK+ that 
>    use g_strconcat ( ... G_DIR_SEPARATOR_S ... ) 
> 
>  - Doing it yourself is ugly on Unix, but fatal on
>    Win32, where \\ in a filename is illegal.
> 
> This is basically a replacement for g_concat_dir_and_file()
> in gnome-libs, which was one of the more commonly used
> convenience functions from gnome-libs.
> 
> I think it would be worth slipping this in, even at this
> point ... I've discussed it with various people in the 
> past, and got favorable reactions but never actually got around 
> to writing anything.

i think they are usefull enough to get in.
however, it'd be good if they also were directly deployed, so
we get rid of the current places which do this on their own.

as for the patch, i consider the first!=NULL stuff a bit hackish in
g_build_pathv(). instead i'd rather see you make it handle the
public API:

gchar *	g_build_filename (const gchar *first_element,
                          ...);
gchar *	g_build_path	 (const gchar *separator,
                          const gchar *first_element,
                          ...);
and not allow first_element==NULL, since there's little point
in supporting g_build_filename(NULL)=="".
also, the docs need a comment that these functions do _not_
return an absolute path.

> 
> Regards,
>                                         Owen
> 

---
ciaoTJ






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]