Make filename work for dirs with trailing slashes.