diff options
author | Roy Marples <roy@marples.name> | 2007-10-04 16:54:29 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-10-04 16:54:29 +0000 |
commit | 87ea3e9e3bfa8e96b31d682f29fc7959bdd1b39e (patch) | |
tree | 78680e84573e0ef6d81ff46fa33c968d8f43f6da /src/librc-misc.c | |
parent | e2e40afddef5253d5d669002b9afbea6bf3d6c66 (diff) |
Punt rc_is_dir
Diffstat (limited to 'src/librc-misc.c')
-rw-r--r-- | src/librc-misc.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/librc-misc.c b/src/librc-misc.c index 29d2763d..4cc69be0 100644 --- a/src/librc-misc.c +++ b/src/librc-misc.c @@ -147,21 +147,6 @@ bool rc_exists (const char *pathname) } librc_hidden_def(rc_exists) -bool rc_is_dir (const char *pathname) -{ - struct stat buf; - - if (! pathname) - return (false); - - if (stat (pathname, &buf) == 0) - return (S_ISDIR (buf.st_mode)); - - errno = 0; - return (false); -} -librc_hidden_def(rc_is_dir) - char **rc_ls_dir (const char *dir, int options) { DIR *dp; @@ -189,6 +174,12 @@ char **rc_ls_dir (const char *dir, int options) d->d_name[l - 1] == 'h') continue; } + if (options & RC_LS_DIRS) { + struct stat buf; + + if (stat (d->d_name, &buf) == 0 && ! S_ISDIR (buf.st_mode)) + continue; + } rc_strlist_addsort (&list, d->d_name); } } @@ -592,7 +583,7 @@ char **rc_env_config (void) We store this special system in RC_SYS so our scripts run fast */ memset (sys, 0, sizeof (sys)); - if (rc_is_dir ("/proc/xen")) { + if (rc_exists ("/proc/xen")) { if ((fp = fopen ("/proc/xen/capabilities", "r"))) { fclose (fp); if (file_regex ("/proc/xen/capabilities", "control_d")) |