* Try reading an entry that is not "." or ".."...
*/
- do
+ for (;;)
{
if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
{
}
DEBUG_printf((" readdir_r() returned \"%s\"...\n", entry->d_name));
- }
- while (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."));
- /*
- * Copy the name over and get the file information...
- */
+ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
+ continue;
- strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));
+ /*
+ * Copy the name over and get the file information...
+ */
- snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);
- if (stat(filename, &(dp->entry.fileinfo)))
- {
- DEBUG_printf((" stat() failed for \"%s\" - %s...\n", filename,
- strerror(errno)));
- return (NULL);
- }
+ strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));
- /*
- * Return the entry...
- */
+ snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);
- return (&(dp->entry));
+ if (stat(filename, &(dp->entry.fileinfo)))
+ {
+ DEBUG_printf((" stat() failed for \"%s\" - %s...\n", filename,
+ strerror(errno)));
+ continue;
+ }
+
+ /*
+ * Return the entry...
+ */
+
+ return (&(dp->entry));
+ }
}