Directory stream received from opendir() function wasn't closed
with proper closedir() function.
This patch fixes this bug.
Change-Id: Ie2a3efb55546251c12a1112861db767595bc374f
#include <errno.h>
#include <fstream>
#include <functional>
+#include <memory>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
return;
}
+ std::unique_ptr<DIR, std::function<void(DIR*)>> dirStream(dirPtr,
+ [](DIR *dir) {
+ if (closedir(dir) < 0) {
+ int err = errno;
+ (void) err;
+ LOGE("'closedir' function error [%d] : <%s>", err, strerror(err));
+ }
+ });
+
while (errno = 0, (direntPtr = readdir(dirPtr)) != nullptr) {
std::string filename = direntPtr->d_name;
//ignore all special files (working dir, parent dir, index, checksums)