"Lars T. Kyllingstad" <public@kyllingen.NOSPAMnet> wrote in message news:ikvsq5$1qr9$2...@digitalmars.com... > On Sun, 06 Mar 2011 09:37:15 +0100, Rainer Schuetze wrote: > >> Looks good overall. I have a few comments and nitpicks though: >> >> > basename("dir/subdir/") --> "subdir" >> > directory("dir/subdir/") --> "dir" >> >> Is this what everybody expects? I'm not sure, but another possibility >> would be to treat these as if "dir/subdir/." is passed. > > I don't know about everybody, but it is what *NIX users expect, at > least. I have written those functions so they adhere to the POSIX > requirements for the 'basename' and 'dirname' commands. >
I initially felt somewhat uncomfortable with the idea of that behavior, but then I realized two things: 1. You don't have to constantly worry about "trailing slash" vs "no trailing slash" and remember the different semantics. (The "trailing slash" vs "no trailing slash" matter can be a real pain.) 2. It'll always treat a path to a directory the same way as a path to a file. (Consistency is nice. Especially since you don't always know if something is intended to be a file or directory.)