]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/dir.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / dir.c
index e06edea91ccc34c20a6874c579b446fab0960ada..1b6bc4369fb70e349c76ea6710f3ad95f59ed71d 100644 (file)
@@ -366,7 +366,7 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory */
   * Try reading an entry that is not "." or ".."...
   */
 
-  do
+  for (;;)
   {
     if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
     {
@@ -381,28 +381,31 @@ cupsDirRead(cups_dir_t *dp)               /* I - Directory */
     }
 
     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));
+  }
 }