bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug and change of ginstall


From: Hideo Saito
Subject: bug and change of ginstall
Date: Mon, 11 Dec 2000 16:05:22 +0900

To  : address@hidden
From: address@hidden (Hideo Saito)
Title: bug and change of ginstall

Hello. My name is H.Saito from Japan.

I report you a bug and a change of ginstall (fileutils-4.0).

bug:
I want to copy a "file" to a new file "ccc" at directory "/tmp/aaa/bbb/".

% ginstall -D file /tmp/aaa/bbb/ccc <return>

If there is no directory "/tmp/aaa",
a file "/tmp/aaa/bbb/file" was created but not "/tmp/aaa/bbb/ccc".

change:
If there is a directory "/tmp/aaa/bbb" already,
I want to copy a "file" to a directory "/tmp/aaa/bbb".
I expect that a new file "/tmp/aaa/bbb/file" will be created.

% ginstall -D file /tmp/aaa/bbb <return>
ginstall: /tmp/aaa/bbb: cannot overwrite directory with non-directory

A error message was issued, and cannot copy "file".

I want to modify Your help message of ginstall, see below.

original:
  -D                  create all leading components of DEST except the last,
                        then copy SOURCE to DEST;  useful in the 1st format
modified:
  -D                  create all leading components of DEST except the last,
                        then copy SOURCE to DEST;  useful in the 1st format
                        or copy to DIRECTORY existed already; 2nd format 

Please reference a my patch.
Thank you. Good bye.
-------------------------------------------------
--- install.c.orig      Mon Oct  5 21:21:58 1998
+++ install.c   Mon Dec 11 12:48:38 2000
@@ -142,6 +142,8 @@
                                         const struct cp_options *x));
 static int install_file_in_dir PARAMS ((const char *from, const char *to_dir,
                                        const struct cp_options *x));
+static int install_file_in_dir_file PARAMS ((const char *from, const char *to, 
const char *to_dir,
+                                       const struct cp_options *x));
 static int install_file_in_file PARAMS ((const char *from, const char *to,
                                         const struct cp_options *x));
 static void get_ids PARAMS ((void));
@@ -426,11 +428,17 @@
                        (x->verbose ? _("creating directory `%s'") : NULL));
 
       if (fail == 0)
-       fail = install_file_in_dir (from, dest_dir, x);
+       fail = install_file_in_dir_file (from, to, dest_dir, x);
     }
   else
     {
-      fail = install_file_in_file (from, to, x);
+      if (isdir(to)) {
+        char *from_base = base_name (from);
+        char *to_file = path_concat (to, from_base, NULL);
+        fail = install_file_in_file (from, to_file, x);
+        free (to_file);
+      } else
+        fail = install_file_in_file (from, to, x);
     }
 
   free (dest_dir);
@@ -473,6 +481,23 @@
   to = path_concat (to_dir, from_base, NULL);
   ret = install_file_in_file (from, to, x);
   free (to);
+  return ret;
+}
+
+static int
+install_file_in_dir_file (const char *from, const char *to, const char *to_dir,
+                    const struct cp_options *x)
+{
+  char *from_base;
+  char *to_file;
+  int ret;
+
+  from_base = base_name (to);
+  if (*from_base == 0)
+    from_base = base_name (from);
+  to_file = path_concat (to_dir, from_base, NULL);
+  ret = install_file_in_file (from, to_file, x);
+  free (to_file);
   return ret;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]