Describe the bug
In convertPathnameToDirName(), the code attempts to remove trailing / characters with:
len = strlen(pathname);
while (pathname[len] == PATH_SEP) {
    pathname[len] = '\0';
    len--;
}However, strlen(pathname) is the index of the terminating NUL.  As a result pathname[len] is always '\0', never '/', so the loop never runs and trailing slashes remain.
To Reproduce
- Call convertPathnameToDirName("foo/bar/").
- Expect "foo/bar", but function returns"foo/bar/".