I'm going to check in a patch for Stdio.append_path for pike 7.8, 7.6 and 7.4.
The changes i have made is to split Stdio.append_path into a NT and a Unix version
(like combine_path).
The problem I solved is for handling drive letters on Windows for the relative path.
The NT version simply strips the second character in the relative path if it is a colon (:).
Index: lib/modules/Stdio.pmod/module.pmod
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.8/lib/modules/Stdio.pmod/module.pmod,v
retrieving revision 1.243
diff -u -r1.243 module.pmod
--- lib/modules/Stdio.pmod/module.pmod 31 Aug 2008 20:17:06 -0000 1.243
+++ lib/modules/Stdio.pmod/module.pmod 3 Dec 2008 09:57:14 -0000
@@ -2230,22 +2230,27 @@
return [int]stat[1];
}
-//! Append @[relative] paths to an @[absolute] path and remove any
-//! @expr{"//"@}, @expr{"../"@} or @expr{"/."@} to produce a
-//! straightforward absolute path as a result.
-//!
-//! @expr{"../"@} is ignorded in the relative paths if it makes the
-//! created path begin with something else than the absolute path
-//! (or so far created path).
+//! @decl string append_path(string absolute, string ... relative)
+//! @decl string append_path_unix(string absolute, string ... relative)
+//! @decl string append_path_nt(string absolute, string ... relative)
+//!
+//! Append @[relative] paths to an @[absolute] path and remove any
+//! @expr{"//"@}, @expr{"../"@} or @expr{"/."@} to produce a
+//! straightforward absolute path as a result.
+//!
+//! @expr{"../"@} is ignorded in the relative paths if it makes the
+//! created path begin with something else than the absolute path
+//! (or so far created path).
+//!
+//! @[append_path()] is equivalent to @[append_path_unix()] on UNIX-like
+//! operating systems, and equivalent to @[append_path_nt()] on NT-like
+//! operating systems.
//!
-//! @note
-//! Warning: This does not work on NT.
-//! (Consider paths like: k:/fnord)
-//!
-//! @seealso
-//! @[combine_path()]
+//! @seealso
+//! @[combine_path()]
//!
-string append_path(string absolute, string ... relative)
+
+string append_path_unix(string absolute, string ... relative)
{
return combine_path(absolute,
@map(relative, lambda(string s) {
@@ -2253,6 +2258,23 @@
}));
}
+string append_path_nt(string absolute, string ... relative)
+{
+ return combine_path(absolute,
+ @map(relative, lambda(string s) {
+ if(s[1..1] == ":") {
+ s = s[0..0] + s[2..];
+ }
+ return combine_path("/", s)[1..];
+ }));
+}
+
+#ifdef __NT__
+function(string, string ... : string) append_path = append_path_nt;
+#else
+function(string, string ... : string) append_path = append_path_unix;
+#endif
+
//! Returns a canonic representation of @[path] (without /./, /../, //
//! and similar path segments).
string simplify_path(string path)