summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-06-16 16:33:34 +0000
committerjkh <jkh@FreeBSD.org>1996-06-16 16:33:34 +0000
commitfe0ca9a717fce956729d30cad29ae708edee6a5a (patch)
treed4a8e106b73d3a6baa60d57a5c6462fd708384be /usr.sbin/pkg_install
parentd797e8dc065b8f9d6ca2e198b499609a9810dd93 (diff)
downloadFreeBSD-src-fe0ca9a717fce956729d30cad29ae708edee6a5a.zip
FreeBSD-src-fe0ca9a717fce956729d30cad29ae708edee6a5a.tar.gz
Make a small optimization which shaves about a second off the time
it takes to build the `All' menu in configPackages.
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/info/perform.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index ed6b259..da142b9 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: perform.c,v 1.17 1995/07/30 01:44:38 ache Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.18 1995/10/25 15:38:31 jkh Exp $";
#endif
/*
@@ -41,35 +41,29 @@ pkg_perform(char **pkgs)
if (!tmp)
tmp = DEF_LOG_DIR;
/* Overriding action? */
- if (AllInstalled || CheckPkg) {
- if (isdir(tmp)) {
- DIR *dirp;
- struct dirent *dp;
-
- dirp = opendir(tmp);
- if (dirp) {
- for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
- if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) {
- if (CheckPkg) {
- if (!strcmp(dp->d_name, CheckPkg))
- return 0;
- }
- else
- err_cnt += pkg_do(dp->d_name);
- }
- }
- (void)closedir(dirp);
- if (CheckPkg)
- return 1;
- }
- else
- ++err_cnt;
- } else if (CheckPkg)
- return 1; /* no dir -> not installed! */
+ if (CheckPkg) {
+ char buf[FILENAME_MAX];
+ snprintf(buf, FILENAME_MAX, "%s/%s", tmp, CheckPkg);
+ return abs(access(buf, R_OK));
}
- for (i = 0; pkgs[i]; i++)
- err_cnt += pkg_do(pkgs[i]);
+ else if (AllInstalled) {
+ DIR *dirp;
+ struct dirent *dp;
+
+ if (!isdir(tmp))
+ return 1;
+ dirp = opendir(tmp);
+ if (dirp) {
+ for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
+ if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, ".."))
+ err_cnt += pkg_do(dp->d_name);
+ (void)closedir(dirp);
+ }
+ }
+ else
+ for (i = 0; pkgs[i]; i++)
+ err_cnt += pkg_do(pkgs[i]);
return err_cnt;
}
OpenPOWER on IntegriCloud