revised implementation for basename, cleanname and dirname.