comparison lisp/net/tramp-smb.el @ 110776:073caec7510f

* net/tramp.el (tramp-handle-directory-files-and-attributes) (tramp-handle-file-exists-p, tramp-handle-file-newer-than-file-p): New defuns, taken from tramp-smb.el. (tramp-coding-system-change-eol-conversion) (tramp-set-process-query-on-exit-flag): Removed. * net/tramp-compat.el (top): Do not check for byte-compiler objects. (tramp-compat-coding-system-change-eol-conversion) (tramp-compat-set-process-query-on-exit-flag): New defuns, taken from tramp.el. * net/tramp-gvfs.el: * net/tramp-gw.el: Replace `tramp-set-process-query-on-exit-flag' by `tramp-compat-set-process-query-on-exit-flag'. * net/tramp-imap.el (tramp-imap-file-name-handler-alist): Use `tramp-handle-directory-files-and-attributes', `tramp-handle-file-exists-p' and `tramp-handle-file-newer-than-file-p'. (tramp-imap-handle-file-exists-p) (tramp-imap-handle-file-executable-p) (tramp-imap-handle-file-readable-p) (tramp-imap-handle-directory-files-and-attributes) (tramp-imap-handle-file-newer-than-file-p): Removed. * net/tramp-sh.el: Replace `tramp-set-process-query-on-exit-flag' by `tramp-compat-set-process-query-on-exit-flag' and `tramp-coding-system-change-eol-conversion' by `tramp-compat-coding-system-change-eol-conversion'. * net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use `tramp-handle-directory-files-and-attributes', `tramp-handle-file-exists-p' and `tramp-handle-file-newer-than-file-p'. (tramp-smb-handle-directory-files-and-attributes) (tramp-smb-handle-file-exists-p) (tramp-smb-handle-file-newer-than-file-p): Removed. (tramp-smb-maybe-open-connection): Replace `tramp-set-process-query-on-exit-flag' by `tramp-compat-set-process-query-on-exit-flag'.
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 05 Oct 2010 16:20:24 +0200
parents d6e88106c5b8
children 49c1b16ca6b1
comparison
equal deleted inserted replaced
110775:6ae391b53988 110776:073caec7510f
151 (delete-file . tramp-smb-handle-delete-file) 151 (delete-file . tramp-smb-handle-delete-file)
152 ;; `diff-latest-backup-file' performed by default handler. 152 ;; `diff-latest-backup-file' performed by default handler.
153 (directory-file-name . tramp-handle-directory-file-name) 153 (directory-file-name . tramp-handle-directory-file-name)
154 (directory-files . tramp-smb-handle-directory-files) 154 (directory-files . tramp-smb-handle-directory-files)
155 (directory-files-and-attributes 155 (directory-files-and-attributes
156 . tramp-smb-handle-directory-files-and-attributes) 156 . tramp-handle-directory-files-and-attributes)
157 (dired-call-process . ignore) 157 (dired-call-process . ignore)
158 (dired-compress-file . ignore) 158 (dired-compress-file . ignore)
159 (dired-uncache . tramp-handle-dired-uncache) 159 (dired-uncache . tramp-handle-dired-uncache)
160 (expand-file-name . tramp-smb-handle-expand-file-name) 160 (expand-file-name . tramp-smb-handle-expand-file-name)
161 (file-accessible-directory-p . tramp-smb-handle-file-directory-p) 161 (file-accessible-directory-p . tramp-smb-handle-file-directory-p)
162 (file-attributes . tramp-smb-handle-file-attributes) 162 (file-attributes . tramp-smb-handle-file-attributes)
163 (file-directory-p . tramp-smb-handle-file-directory-p) 163 (file-directory-p . tramp-smb-handle-file-directory-p)
164 (file-executable-p . tramp-smb-handle-file-exists-p) 164 (file-executable-p . tramp-handle-file-exists-p)
165 (file-exists-p . tramp-smb-handle-file-exists-p) 165 (file-exists-p . tramp-handle-file-exists-p)
166 (file-local-copy . tramp-smb-handle-file-local-copy) 166 (file-local-copy . tramp-smb-handle-file-local-copy)
167 (file-modes . tramp-handle-file-modes) 167 (file-modes . tramp-handle-file-modes)
168 (file-name-all-completions . tramp-smb-handle-file-name-all-completions) 168 (file-name-all-completions . tramp-smb-handle-file-name-all-completions)
169 (file-name-as-directory . tramp-handle-file-name-as-directory) 169 (file-name-as-directory . tramp-handle-file-name-as-directory)
170 (file-name-completion . tramp-handle-file-name-completion) 170 (file-name-completion . tramp-handle-file-name-completion)
171 (file-name-directory . tramp-handle-file-name-directory) 171 (file-name-directory . tramp-handle-file-name-directory)
172 (file-name-nondirectory . tramp-handle-file-name-nondirectory) 172 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
173 ;; `file-name-sans-versions' performed by default handler. 173 ;; `file-name-sans-versions' performed by default handler.
174 (file-newer-than-file-p . tramp-smb-handle-file-newer-than-file-p) 174 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
175 (file-ownership-preserved-p . ignore) 175 (file-ownership-preserved-p . ignore)
176 (file-readable-p . tramp-smb-handle-file-exists-p) 176 (file-readable-p . tramp-handle-file-exists-p)
177 (file-regular-p . tramp-handle-file-regular-p) 177 (file-regular-p . tramp-handle-file-regular-p)
178 (file-remote-p . tramp-handle-file-remote-p) 178 (file-remote-p . tramp-handle-file-remote-p)
179 ;; `file-selinux-context' performed by default handler. 179 ;; `file-selinux-context' performed by default handler.
180 (file-symlink-p . tramp-handle-file-symlink-p) 180 (file-symlink-p . tramp-handle-file-symlink-p)
181 ;; `file-truename' performed by default handler. 181 ;; `file-truename' performed by default handler.
448 result))) 448 result)))
449 ;; Sort them if necessary. 449 ;; Sort them if necessary.
450 (unless nosort (setq result (sort result 'string-lessp))) 450 (unless nosort (setq result (sort result 'string-lessp)))
451 ;; That's it. 451 ;; That's it.
452 result)) 452 result))
453
454 (defun tramp-smb-handle-directory-files-and-attributes
455 (directory &optional full match nosort id-format)
456 "Like `directory-files-and-attributes' for Tramp files."
457 (mapcar
458 (lambda (x)
459 (cons x (tramp-compat-file-attributes
460 (if full x (expand-file-name x directory)) id-format)))
461 (directory-files directory full match nosort)))
462 453
463 (defun tramp-smb-handle-expand-file-name (name &optional dir) 454 (defun tramp-smb-handle-expand-file-name (name &optional dir)
464 "Like `expand-file-name' for Tramp files." 455 "Like `expand-file-name' for Tramp files."
465 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". 456 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
466 (setq dir (or dir default-directory "/")) 457 (setq dir (or dir default-directory "/"))
595 (defun tramp-smb-handle-file-directory-p (filename) 586 (defun tramp-smb-handle-file-directory-p (filename)
596 "Like `file-directory-p' for Tramp files." 587 "Like `file-directory-p' for Tramp files."
597 (and (file-exists-p filename) 588 (and (file-exists-p filename)
598 (eq ?d (aref (nth 8 (file-attributes filename)) 0)))) 589 (eq ?d (aref (nth 8 (file-attributes filename)) 0))))
599 590
600 (defun tramp-smb-handle-file-exists-p (filename)
601 "Like `file-exists-p' for Tramp files."
602 (not (null (file-attributes filename))))
603
604 (defun tramp-smb-handle-file-local-copy (filename) 591 (defun tramp-smb-handle-file-local-copy (filename)
605 "Like `file-local-copy' for Tramp files." 592 "Like `file-local-copy' for Tramp files."
606 (with-parsed-tramp-file-name filename nil 593 (with-parsed-tramp-file-name filename nil
607 (unless (file-exists-p filename) 594 (unless (file-exists-p filename)
608 (tramp-error 595 (tramp-error
635 (list 622 (list
636 (if (string-match "d" (nth 1 x)) 623 (if (string-match "d" (nth 1 x))
637 (file-name-as-directory (nth 0 x)) 624 (file-name-as-directory (nth 0 x))
638 (nth 0 x)))) 625 (nth 0 x))))
639 entries))))))) 626 entries)))))))
640
641 (defun tramp-smb-handle-file-newer-than-file-p (file1 file2)
642 "Like `file-newer-than-file-p' for Tramp files."
643 (cond
644 ((not (file-exists-p file1)) nil)
645 ((not (file-exists-p file2)) t)
646 (t (tramp-time-less-p (nth 5 (file-attributes file2))
647 (nth 5 (file-attributes file1))))))
648 627
649 (defun tramp-smb-handle-file-writable-p (filename) 628 (defun tramp-smb-handle-file-writable-p (filename)
650 "Like `file-writable-p' for Tramp files." 629 "Like `file-writable-p' for Tramp files."
651 (if (file-exists-p filename) 630 (if (file-exists-p filename)
652 (string-match "w" (or (nth 8 (file-attributes filename)) "")) 631 (string-match "w" (or (nth 8 (file-attributes filename)) ""))
1321 (tramp-buffer-name vec) (tramp-get-buffer vec) 1300 (tramp-buffer-name vec) (tramp-get-buffer vec)
1322 tramp-smb-program args)))) 1301 tramp-smb-program args))))
1323 1302
1324 (tramp-message 1303 (tramp-message
1325 vec 6 "%s" (mapconcat 'identity (process-command p) " ")) 1304 vec 6 "%s" (mapconcat 'identity (process-command p) " "))
1326 (tramp-set-process-query-on-exit-flag p nil) 1305 (tramp-compat-set-process-query-on-exit-flag p nil)
1327 1306
1328 ;; Set variables for computing the prompt for reading password. 1307 ;; Set variables for computing the prompt for reading password.
1329 (setq tramp-current-method tramp-smb-method 1308 (setq tramp-current-method tramp-smb-method
1330 tramp-current-user user 1309 tramp-current-user user
1331 tramp-current-host host) 1310 tramp-current-host host)