summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2007-07-02 00:57:47 +0200
committerDan McGee <dan@archlinux.org>2007-07-01 22:32:18 -0400
commit89ed15c9c2dd5449d50e5ec2283a4d6ebac5f328 (patch)
treec021c1221d15c4a7e98226aaf473af781152ef72 /src
parent7a42e24400499873c3b9e1e2315edc808d753734 (diff)
downloadpacman-89ed15c9c2dd5449d50e5ec2283a4d6ebac5f328.tar.xz
pacman/packages.c : print an error for files that can't be stated.
The -Ql operation is supposed to print all files but directories. stat was used for detecting directories. However, when stat failed, (because the file doesn't exist or is not readable), the files were still displayed just like the others. Now, these files are printed on stderr, with the corresponding error message. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/package.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c
index c91384d9..a30260ae 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
+#include <errno.h>
#include <alpm.h>
#include <alpm_list.h>
@@ -222,14 +223,18 @@ void dump_pkg_files(pmpkg_t *pkg)
filestr = (char*)alpm_list_getdata(i);
/* build a path so we can stat the filename */
snprintf(path, PATH_MAX-1, "%s%s", root, filestr);
- if(!stat(path, &buf) && S_ISDIR(buf.st_mode)) {
- /* if we stat it and it is a dir, don't print */
+ if(!lstat(path, &buf)) {
+ if(!S_ISDIR(buf.st_mode)) {
+ /* don't print directories */
+ fprintf(stdout, "%s %s\n", pkgname, path);
+ }
} else {
- fprintf(stdout, "%s %s\n", pkgname, path);
+ fprintf(stderr, "%s %s : %s\n", pkgname, path, strerror(errno));
}
}
fflush(stdout);
+ fflush(stderr);
}
/* Display the changelog of an installed package