]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
add ply_list_directory function
authorRay Strode <rstrode@redhat.com>
Sun, 21 Oct 2007 22:31:12 +0000 (18:31 -0400)
committerRay Strode <rstrode@redhat.com>
Sun, 21 Oct 2007 22:33:34 +0000 (18:33 -0400)
It just does ls -R basically, but it's useful for debugging.

src/libply/ply-utils.c
src/libply/ply-utils.h

index 33337a9e884958a5c8d879fe3ccc339fcc5c1142..0bd901b477b41b527f403624c4519c33ab150df2 100644 (file)
@@ -571,6 +571,44 @@ ply_file_exists (const char *file)
   return S_ISREG (file_info.st_mode);
 }
 
+void 
+ply_list_directory (const char *path)
+{
+  DIR *dir;
+  struct dirent *entry;
+  static int level = 0;
+
+  dir = opendir (path);
+
+  if (dir == NULL)
+    return;
+
+  if (level > 5)
+    return;
+
+  int index = 0;
+  while ((entry = readdir (dir)) != NULL) 
+    {
+      char *subdir;
+
+      index++;
+
+      if (index > 10)
+        break;
+
+      subdir = NULL;
+      asprintf (&subdir, "%s/%s", path, entry->d_name);
+      ply_error ("%s ", subdir);
+      level++;
+      if (entry->d_name[0] != '.')
+        ply_list_directory (subdir);
+      level--;
+      free (subdir);
+    }
+
+  closedir (dir);
+}
+
 ply_module_handle_t *
 ply_open_module (const char *module_path)
 {
index ec46fef2618509290ea93b2fe3444bfc12674184..dea2ab3f93f169da44b1cf27c8f18da49e03ef35 100644 (file)
@@ -69,6 +69,7 @@ void ply_restore_errno (void);
 
 bool ply_directory_exists (const char *dir);
 bool ply_file_exists (const char *file);
+void ply_list_directory (const char *dir);
 
 ply_module_handle_t *ply_open_module (const char *module_path);
 ply_module_function_t ply_module_look_up_function (ply_module_handle_t *handle,