Re: join_path
- Posted by gbonvehi Feb 23, 2013
- 1235 views
mattlewis said...
I was using join_path in std/filesys.e, and found what I think is probably a bug. Basically, I did (on Windows, obviously):
-- expected foo = `C:\foo\bar\baz` -- actual foo = `\C:\foo\bar\baz` foo = join_path( { `C:\foo\bar`, "baz" } )
Is this a bug, or am I missing something about this function?
Matt
As Greg quoted, it seems not to be a bug but the documented behavior. However, I wouldn't expect it to add the leading directory separator char as for example, if you're using relative paths, you wouldn't want it to be added.
Normally standard libraries concatenate the strings using the fsystem's directory separator char.
-- win foo = join_path( { `C:\foo\bar`, "baz" } ) -- foo = `C:\foo\bar\baz` foo = join_path( { `foo\bar`, "baz" } ) -- foo = `foo\bar\baz` -- *nix foo = join_path( { `/foo/bar`, "baz" } ) -- foo = `/foo/bar/baz` foo = join_path( { `foo/bar`, "baz" } ) -- foo = `foo/bar/baz`