utils: use warnings for uncommon situations when checking emptiness

When we check for emptiness of a directory, use `log_warn()` for
uncommon situations, like not being able to open the directory or not
being able to read it.

Also set errno to 0 before using `readdir()` since it can return
`NULL` with `errno` unchanged.