[Haskell-cafe] File path programme

Jules Bean jules at jellybean.co.uk
Tue Jan 25 06:58:16 EST 2005

On 25 Jan 2005, at 11:32, Krasimir Angelov wrote:

>>  splitFileName "/foo/bar" ==> ("/foo","bar")
>>  splitFileName "/foo//bar" ==> ("/foo/","bar")
>>    (definitely a bug)
> Is "/foo//bar" valid file path and what does "//" mean?
>>  pathParents "/foo///bar" ==> ["/","/foo","/foo","/foo","/foo/bar"]
> Again what does "///" mean?

Under implementations of unix that I have played with, extra // are 
ignored. So "/foo//bar" == "/foo/bar" == "/foo///bar". I have no idea 
if this is in some standard.

My guess is that it is made so that programs which concatenate paths 
clumsily can cope OK, so you can do "/foo" ++ "/" ++ "bar" or "/foo/" 
++ "/" ++ "bar" and get the same results: i.e. it is an extension of 
the notion that "/foo/" and "/foo" refer to the same directory. 
(Except, apparently, in the presence of symbolic links... or so I have 
some vague memory)


More information about the Haskell-Cafe mailing list