filepath should not return trailing path separators

Neil Mitchell ndmitchell at
Fri Jun 15 05:36:46 EDT 2007


> > The root of my problem is that splitFileName leaves a trailing path
> > separator on the end of the first element of the tuple it returns:
> >
> >   splitFileName "foo/bar" ==> ("foo/", "bar")
> >
> > If I'm recursing up a file hierarchy towards the root directory (a
> > common thing to do), this trailing path separator is a pain.  Either I
> > forget that it's there and infinitely loop in the same directory over
> > and over again, due to this behaviour:
> >
> >   splitFileName "foo/" ==> ("foo/", "")
> FWIW I think you're right here.

In various discussions I think people argued for both - in "foo/"
there  is no filename, since foo has been explicitly marked as a
directory. I guess in this case foo is actually the leafname, or

If you are doing your recursion pattern I think takeDirectory would be
better, since it always progresses upwards. I didn't intend people to
call the split* functions that much.

I'm happy with whatever consensus people reach.



More information about the Libraries mailing list