#include <string.h>
#include <dirent.h>
#include <unistd.h>
+#include <errno.h>
#include <tzplatform_config.h>
}
int ret = WAE_ERROR_NONE;
- struct dirent entry;
- struct dirent *result = NULL;
while (true) {
- if (readdir_r(dir, &entry, &result) != 0) {
- WAE_SLOGE("readdir_r error on dir(%s) errno(%d)", path, errno);
+ errno = 0;
+ struct dirent *result = readdir(dir);
+ if (result == NULL) {
+ if (errno != 0)
+ WAE_SLOGE("readdir error on dir(%s) errno(%d)", path, errno);
break;
- } else if (result == NULL) {
- break; // end of directory
- } else if (strcmp(entry.d_name, ".") == 0 || strcmp(entry.d_name, "..") == 0) {
+ } else if (strcmp(result->d_name, ".") == 0 ||
+ strcmp(result->d_name, "..") == 0) {
continue;
}