g_build_filename() documentation claims that:

On Windows, it takes into account that either the backslash (|\)| or
slash (|/|) can be used as separator in filenames, but otherwise behaves
as on Unix. When file pathname separators need to be inserted, the one
that last previously occurred in the parameters (reading from left to
right) is used.

Reader could imagine that g_build_filename() scans each parameter before
appending it to resulting string and looks for path separators. The last
path separator found in a parameter is then used as path separator
between current parameter and next parameter (it might be that if next
parameter starts with a path separator, then none is inserted, but
that's besides the point).
However, in reality it's quite different. Instead of scanning each
parameter, g_build_filename() (actually, it's g_build_pathname_va(), but
that's besides the point) looks in a parameter for the first continuous
set of separators and the last set of continuous separators (that is, in
a string "//\\\/\//abcd//ef//gh//ij\\\/\/\///" that would be "//\\\/\//"
and "\\\/\/\///") and assigns the last separator of the first set or (if
it is present) the first separator of the last set as current separator
(in case of "//\\\/\//abcd//ef//gh//ij\\\/\/\///" that would be '\\',
assuming that double backslash is an escaped form of single backslash).
That is, if you call g_build_filename("c:/dir/subdir", "filename",
NULL), you'll get "c:/dir/subdir\\filename" as a result.

_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to