* net/dbus.el (dbus-hash-table=): Fix for new hash table key
[bpt/emacs.git] / lisp / net / tramp-fish.el
index 8ae6af7..95091c2 100644 (file)
@@ -308,10 +308,10 @@ pass to the OPERATION."
         v1 'file-error "Error with add-name-to-file %s" newname)))))
 
 (defun tramp-fish-handle-copy-file
-  (filename newname &optional ok-if-already-exists keep-date)
+  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
   "Like `copy-file' for Tramp files."
   (tramp-fish-do-copy-or-rename-file
-   'copy filename newname ok-if-already-exists keep-date))
+   'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
 
 (defun tramp-fish-handle-delete-directory (directory)
   "Like `delete-directory' for Tramp files."
@@ -346,7 +346,7 @@ pass to the OPERATION."
   ;; Unless NAME is absolute, concat DIR and NAME.
   (unless (file-name-absolute-p name)
     (setq name (concat (file-name-as-directory dir) name)))
-  ;; If NAME is not a tramp file, run the real handler
+  ;; If NAME is not a Tramp file, run the real handler,
   (if (or (tramp-completion-mode-p) (not (tramp-tramp-file-p name)))
       (tramp-drop-volume-letter
        (tramp-run-real-handler 'expand-file-name (list name nil)))
@@ -475,7 +475,7 @@ pass to the OPERATION."
       (tramp-error
        v 'file-error
        "Cannot make local copy of non-existing file `%s'" filename))
-    (let ((tmpfile (tramp-make-temp-file filename)))
+    (let ((tmpfile (tramp-compat-make-temp-file filename)))
       (tramp-message v 4 "Fetching %s to tmp file %s..." filename tmpfile)
       (when (tramp-fish-retrieve-data v)
        ;; Save file
@@ -734,8 +734,8 @@ target of the symlink differ."
     (error "Implementation does not handle immediate return"))
 
   (with-parsed-tramp-file-name default-directory nil
-    (let ((temp-name-prefix (tramp-make-tramp-temp-file v))
-         command input output stderr outbuf tmpfile ret)
+    (let (command input tmpinput output tmpoutput stderr tmpstderr
+                 outbuf tmpfile ret)
       ;; Compute command.
       (setq command (mapconcat 'tramp-shell-quote-argument
                               (cons program args) " "))
@@ -747,15 +747,14 @@ target of the symlink differ."
            ;; INFILE is on the same remote host.
            (setq input (with-parsed-tramp-file-name infile nil localname))
          ;; INFILE must be copied to remote host.
-         (setq input (concat temp-name-prefix ".in"))
-         (copy-file
-          infile
-          (tramp-make-tramp-file-name method user host input)
-          t)))
+         (setq input (tramp-make-tramp-temp-file v)
+               tmpinput (tramp-make-tramp-file-name method user host input))
+         (copy-file infile tmpinput t)))
       (when input (setq command (format "%s <%s" command input)))
 
       ;; Determine output.
-      (setq output (concat temp-name-prefix ".out"))
+      (setq output (tramp-make-tramp-temp-file v)
+           tmpoutput (tramp-make-tramp-file-name method user host output))
       (cond
        ;; Just a buffer
        ((bufferp destination)
@@ -781,7 +780,9 @@ target of the symlink differ."
                               (cadr destination) nil localname))
            ;; stderr must be copied to remote host.  The temporary
            ;; file must be deleted after execution.
-           (setq stderr (concat temp-name-prefix ".err"))))
+           (setq stderr (tramp-make-tramp-temp-file v)
+                 tmpstderr (tramp-make-tramp-file-name
+                            method user host stderr))))
         ;; stderr to be discarded
         ((null (cadr destination))
          (setq stderr "/dev/null"))))
@@ -790,9 +791,6 @@ target of the symlink differ."
        (setq outbuf (current-buffer))))
       (when stderr (setq command (format "%s 2>%s" command stderr)))
 
-      ;; If we have a temporary file, it must be removed after operation.
-      (when (and input (string-match temp-name-prefix input))
-       (setq command (format "%s; rm %s" command input)))
       ;; Goto working directory.
       (unless
          (tramp-fish-send-command-and-check
@@ -821,16 +819,15 @@ target of the symlink differ."
            ;; We should show the output anyway.
            (when outbuf
              (with-current-buffer outbuf (insert-file-contents tmpfile))
-             (when display (display-buffer outbuf)))
-           ;; Remove output file.
-           (delete-file (tramp-make-tramp-file-name method user host output)))
+             (when display (display-buffer outbuf))))
        ;; When the user did interrupt, we should do it also.
        (error (setq ret 1)))
-      (unless ret
-       ;; Provide error file.
-       (when (and stderr (string-match temp-name-prefix stderr))
-         (rename-file (tramp-make-tramp-file-name method user host stderr)
-                      (cadr destination) t)))
+
+      ;; Provide error file.
+      (when tmpstderr (rename-file tmpstderr (cadr destination) t))
+      ;; Cleanup.
+      (when tmpinput (delete-file tmpinput))
+      (when tmpoutput (delete-file tmpoutput))
       ;; Return exit status.
       ret)))
 
@@ -838,7 +835,7 @@ target of the symlink differ."
 ;; Internal file name functions
 
 (defun tramp-fish-do-copy-or-rename-file
-  (op filename newname &optional ok-if-already-exists keep-date)
+  (op filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
   "Copy or rename a remote file.
 OP must be `copy' or `rename' and indicates the operation to
 perform.  FILENAME specifies the file to copy or rename, NEWNAME
@@ -872,7 +869,7 @@ file names."
           ;; directly.
           ((tramp-equal-remote filename newname)
            (tramp-fish-do-copy-or-rename-file-directly
-            op filename newname keep-date))
+            op filename newname keep-date preserve-uid-gid))
           ;; No shortcut was possible.  So we copy the
           ;; file first.  If the operation was `rename', we go
           ;; back and delete the original file (if the copy was
@@ -902,12 +899,13 @@ file names."
          (tramp-flush-file-property v (file-name-directory localname)))))))
 
 (defun tramp-fish-do-copy-or-rename-file-directly
-  (op filename newname keep-date)
+  (op filename newname keep-date preserve-uid-gid)
   "Invokes `COPY' or `RENAME' on the remote system.
 OP must be one of `copy' or `rename', indicating `cp' or `mv',
 respectively.  VEC specifies the connection.  LOCALNAME1 and
 LOCALNAME2 specify the two arguments of `cp' or `mv'.  If
-KEEP-DATE is non-nil, preserve the time stamp when copying."
+KEEP-DATE is non-nil, preserve the time stamp when copying.
+PRESERVE-UID-GID is completely ignored."
   (with-parsed-tramp-file-name filename v1
     (with-parsed-tramp-file-name newname v2
       (tramp-fish-send-command