Commit 288f783b authored by Michael Albinus's avatar Michael Albinus

* net/tramp-smb.el (tramp-smb-handle-copy-directory): Handle the

case both directories are remote.
(tramp-smb-handle-expand-file-name): Implement "~" expansion.
(tramp-smb-maybe-open-connection): Flush the cache only if
necessary.
parent a17632c1
2009-10-08 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-file-name-real-user, tramp-file-name-domain)
(tramp-file-name-real-host, tramp-file-name-port): Apply
`save-match-data.
* net/tramp-smb.el (tramp-smb-handle-copy-directory): Handle the
case both directories are remote.
(tramp-smb-handle-expand-file-name): Implement "~" expansion.
(tramp-smb-maybe-open-connection): Flush the cache only if
necessary.
2009-10-08 Chong Yidong <cyd@stupidchicken.com> 2009-10-08 Chong Yidong <cyd@stupidchicken.com>
* cedet/ede/proj-obj.el (ede-gcc-linker): New var. * cedet/ede/proj-obj.el (ede-gcc-linker): New var.
......
...@@ -218,40 +218,53 @@ pass to the OPERATION." ...@@ -218,40 +218,53 @@ pass to the OPERATION."
(let ((t1 (tramp-tramp-file-p dirname)) (let ((t1 (tramp-tramp-file-p dirname))
(t2 (tramp-tramp-file-p newname))) (t2 (tramp-tramp-file-p newname)))
(with-parsed-tramp-file-name (if t1 dirname newname) nil (with-parsed-tramp-file-name (if t1 dirname newname) nil
(if (or (null t1) (null t2)) (cond
;; We can copy recursively. ((and t1 t2)
(let ((prompt (tramp-smb-send-command v "prompt")) ;; We must copy, using a local temporary directory.
(recurse (tramp-smb-send-command v "recurse"))) (let ((tmpdir
(unless (file-directory-p newname) (make-temp-name
(make-directory newname parents)) (expand-file-name
(unwind-protect tramp-temp-name-prefix
(unless (tramp-compat-temporary-file-directory)))))
(and (unwind-protect
prompt recurse (progn
(tramp-smb-send-command (copy-directory dirname tmpdir keep-date parents)
v (format "cd \"%s\"" (copy-directory tmpdir newname keep-date parents))
(tramp-smb-get-localname localname t))) (delete-directory tmpdir 'recursive))))
(tramp-smb-send-command ((or t1 t2)
v (format "lcd \"%s\"" (if t1 newname dirname))) ;; We can copy recursively.
(if t1 (let ((prompt (tramp-smb-send-command v "prompt"))
(tramp-smb-send-command v "mget *") (recurse (tramp-smb-send-command v "recurse")))
(tramp-smb-send-command v "mput *"))) (unless (file-directory-p newname)
;; Error. (make-directory newname parents))
(with-current-buffer (tramp-get-connection-buffer v) (unwind-protect
(goto-char (point-min)) (unless
(search-forward-regexp tramp-smb-errors nil t) (and
(tramp-error prompt recurse
v 'file-error (tramp-smb-send-command
"%s `%s'" (match-string 0) (if t1 dirname newname)))) v (format "cd \"%s\""
;; Always go home. (tramp-smb-get-localname localname t)))
(tramp-smb-send-command v (format "cd \\")) (tramp-smb-send-command
;; Toggle prompt and recurse OFF. v (format "lcd \"%s\"" (if t1 newname dirname)))
(if prompt (tramp-smb-send-command v "prompt")) (if t1
(if recurse (tramp-smb-send-command v "recurse")))) (tramp-smb-send-command v "mget *")
(tramp-smb-send-command v "mput *")))
;; Error.
(with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min))
(search-forward-regexp tramp-smb-errors nil t)
(tramp-error
v 'file-error
"%s `%s'" (match-string 0) (if t1 dirname newname))))
;; Always go home.
(tramp-smb-send-command v (format "cd \\"))
;; Toggle prompt and recurse OFF.
(if prompt (tramp-smb-send-command v "prompt"))
(if recurse (tramp-smb-send-command v "recurse")))))
(t
;; We must do it file-wise. ;; We must do it file-wise.
(tramp-run-real-handler (tramp-run-real-handler
'copy-directory (list dirname newname keep-date parents)))))) 'copy-directory (list dirname newname keep-date parents)))))))
(defun tramp-smb-handle-copy-file (defun tramp-smb-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid) (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
...@@ -400,17 +413,18 @@ PRESERVE-UID-GID is completely ignored." ...@@ -400,17 +413,18 @@ PRESERVE-UID-GID is completely ignored."
(tramp-run-real-handler 'expand-file-name (list name nil)) (tramp-run-real-handler 'expand-file-name (list name nil))
;; Dissect NAME. ;; Dissect NAME.
(with-parsed-tramp-file-name name nil (with-parsed-tramp-file-name name nil
(unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
(setq localname (concat "/" localname)))
;; Tilde expansion if necessary. We use the user name as share, ;; Tilde expansion if necessary. We use the user name as share,
;; which is offen the case in work groups. ;; which is offen the case in domains.
(when (string-match "\\`~[^/]*" localname) (when (string-match "\\`/?~\\([^/]*\\)" localname)
(setq localname (setq localname
(replace-match (replace-match
(if (zerop (length (match-string 0 localname))) (if (zerop (length (match-string 1 localname)))
(tramp-file-name-real-user v) (tramp-file-name-real-user v)
(match-string 0 localname)) (match-string 1 localname))
nil nil localname))) nil nil localname)))
;; Make the file name absolute.
(unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
(setq localname (concat "/" localname)))
;; No tilde characters in file name, do normal ;; No tilde characters in file name, do normal
;; `expand-file-name' (this does "/./" and "/../"). ;; `expand-file-name' (this does "/./" and "/../").
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
...@@ -1000,11 +1014,12 @@ connection if a previous connection has died for some reason." ...@@ -1000,11 +1014,12 @@ connection if a previous connection has died for some reason."
(unless (string-equal (unless (string-equal
smbclient-version smbclient-version
(tramp-get-connection-property vec "smbclient-version" "")) (tramp-get-connection-property vec "smbclient-version" ""))
(tramp-flush-directory-property vec "") (when (tramp-get-connection-property vec "smbclient-version" nil)
(tramp-flush-connection-property vec) (tramp-flush-directory-property vec "")
(tramp-flush-connection-property vec)
); (setq buf (tramp-get-buffer vec)))
(tramp-set-connection-property (tramp-set-connection-property
vec "smbclient-version" smbclient-version) vec "smbclient-version" smbclient-version))))
(setq buf (tramp-get-buffer vec)))))
;; If too much time has passed since last command was sent, look ;; If too much time has passed since last command was sent, look
;; whether there has been an error message; maybe due to ;; whether there has been an error message; maybe due to
...@@ -1089,12 +1104,14 @@ connection if a previous connection has died for some reason." ...@@ -1089,12 +1104,14 @@ connection if a previous connection has died for some reason."
(search-forward-regexp (search-forward-regexp
"Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t) "Domain=\\[[^]]*\\] OS=\\[[^]]*\\] Server=\\[[^]]*\\]" nil t)
(let ((smbserver-version (match-string 0))) (let ((smbserver-version (match-string 0)))
(when (not (string-equal (unless (string-equal
smbserver-version smbserver-version
(tramp-get-connection-property (tramp-get-connection-property
vec "smbserver-version" ""))) vec "smbserver-version" ""))
(tramp-flush-directory-property vec "") (when (tramp-get-connection-property
(tramp-flush-connection-property vec) vec "smbserver-version" nil)
(tramp-flush-directory-property vec "")
(tramp-flush-connection-property vec))
(tramp-set-connection-property (tramp-set-connection-property
vec "smbserver-version" smbserver-version)))) vec "smbserver-version" smbserver-version))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment