Why not use dirname(3) ?