fileutil: fix a resource leak where closedir wasn't called on Linux and CloseFind wasn't called on Windows (Coverity)