summaryrefslogtreecommitdiff
path: root/src/install.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-08-02 20:14:39 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-08-02 20:14:39 +0000
commit1dfc8b472e5f973cfa7c4818d65b962442b5cfba (patch)
treecc105c74b8e81c104447c0eb193200931e22350e /src/install.c
parente4d5fc228349cf93a89fa184ba0d1e5db52d5fc0 (diff)
downloadcoreutils-1dfc8b472e5f973cfa7c4818d65b962442b5cfba.tar.xz
(isdir): Remove decl.
(install_file_to_path): Rely on make_path to fail if the destination is not a directory, by passing preserve_existing==true to it. Hence we no longer need to call isdir. Free dest_dir immediately when it's no longer needed, rather than waiting until the end of the function. (copy_file): Don't bother calling isdir, as copy will do the right thing if the destination is a directory.
Diffstat (limited to 'src/install.c')
-rw-r--r--src/install.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/install.c b/src/install.c
index 38a43d6d8..5879ecab2 100644
--- a/src/install.c
+++ b/src/install.c
@@ -72,8 +72,6 @@ gid_t getgid ();
/* Number of bytes of a file to copy at a time. */
#define READ_SIZE (32 * 1024)
-bool isdir (char const *);
-
int stat ();
static bool change_timestamps (const char *from, const char *to);
@@ -414,29 +412,26 @@ static bool
install_file_to_path (const char *from, const char *to,
const struct cp_options *x)
{
- char *dest_dir;
+ char *dest_dir = dir_name (to);
bool ok = true;
- dest_dir = dir_name (to);
-
- /* check to make sure this is a path (not install a b ) */
- if (!STREQ (dest_dir, ".")
- && !isdir (dest_dir))
+ /* Make sure that the parent of the destination is a directory. */
+ if (! STREQ (dest_dir, "."))
{
/* Someone will probably ask for a new option or three to specify
owner, group, and permissions for parent directories. Remember
that this option is intended mainly to help installers when the
distribution doesn't provide proper install rules. */
#define DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
- ok = make_path (dest_dir, DIR_MODE, DIR_MODE, owner_id, group_id, false,
+ ok = make_path (dest_dir, DIR_MODE, DIR_MODE, owner_id, group_id, true,
(x->verbose ? _("creating directory %s") : NULL));
}
+ free (dest_dir);
+
if (ok)
ok = install_file_in_file (from, to, x);
- free (dest_dir);
-
return ok;
}
@@ -484,12 +479,9 @@ copy_file (const char *from, const char *to, const struct cp_options *x)
/* Allow installing from non-regular files like /dev/null.
Charles Karney reported that some Sun version of install allows that
- and that sendmail's installation process relies on the behavior. */
- if (isdir (from))
- {
- error (0, 0, _("%s is a directory"), quote (from));
- return false;
- }
+ and that sendmail's installation process relies on the behavior.
+ However, since !x->recursive, the call to "copy" will fail if FROM
+ is a directory. */
return copy (from, to, false, x, &copy_into_self, NULL);
}