Replace `scandir` with `DirectoryIterator`