closedir usage make it work reliably over recursive operations