fix #220: the first entry is not necessarily a directory

in that case, we use dirname() on the first entry