Replace `scandir` by `FilesystemIterator`

1. `scandir` is slow compared to `FilesystemIterator`,
2. `FilesystemIterator::SKIP_DOTS` is cross-FS,
3. using an iterator is better than looping on a huge array (in the case
   where there is a lot of entries in the directory), it saves memory.