better ifdef test for DIRENT feature with thanks to Brian Ripley