
Beman Dawes wrote:
Beman Dawes wrote:
...An alternative set I'd be comfortable with would be tail() for the current leaf() and head_path() for the current branch_path().
Hum... After sending that, I read Johan RĂ¥de's "parent" suggestion.
I really like parent_path() for the current branch_path().
Sorry for the bikeshedding, but I really don't like parent_path. The problem I see is related to symbolic links. "parent" suggests a parent directory, even though parent_path() might return something that is not the parent directory of a link target. I think the naming should reflect the fact that we're operating on names only, not on an actual filesystem structure. So, IMHO, "basename" is a better choice than anything containing "parent". A sketch might help to understand the situation; consider this structure: /x: drwxr-xr-x 2 root root 72 2008-05-29 18:52 left drwxr-xr-x 3 root root 72 2008-05-29 18:52 right1 /x/left: -rw-r--r-- 1 root root 5 2008-05-29 18:52 foo /x/right1: drwxr-xr-x 2 root root 72 2008-05-29 18:55 right2 /x/right1/right2: lrwxrwxrwx 1 root root 10 2008-05-29 18:55 bar -> ../../left basename(/x/right1/right2/bar) will return /x/right1/right2 open(basename(/x/right1/right2/bar)) will open something different than open((/x/right1/right2/bar/..)), as can be demonstrated by using ls:
ls -l /x/right1/right2 lrwxrwxrwx 1 root root 10 2008-05-29 18:55 bar -> ../../left
ls -l /x/right1/right2/bar/.. drwxr-xr-x 2 root root 72 2008-05-29 18:52 left drwxr-xr-x 3 root root 72 2008-05-29 18:52 right1
So, "basename()" and "parent_of()" should be considered operations on different domains (path names vs filesystem). Regards, m