replace deprecated readdir_r() with readdir()