From: Ray Strode Date: Sun, 21 Oct 2007 22:31:12 +0000 (-0400) Subject: add ply_list_directory function X-Git-Tag: 0.1.0~143^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b41b2a8ed464d39afde09e6c13054a176ad34f6d;p=thirdparty%2Fplymouth.git add ply_list_directory function It just does ls -R basically, but it's useful for debugging. --- diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index 33337a9e..0bd901b4 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -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) { diff --git a/src/libply/ply-utils.h b/src/libply/ply-utils.h index ec46fef2..dea2ab3f 100644 --- a/src/libply/ply-utils.h +++ b/src/libply/ply-utils.h @@ -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,