make readdir file type check more generic