comparison lisp/net/tramp.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 029e4783cbae
comparison
equal deleted inserted replaced
110775:6ae391b53988 110776:073caec7510f
2607 (file-directory-p item))) 2607 (file-directory-p item)))
2608 (push (if full (concat directory item) item) 2608 (push (if full (concat directory item) item)
2609 result))) 2609 result)))
2610 (if nosort result (sort result 'string<))))) 2610 (if nosort result (sort result 'string<)))))
2611 2611
2612 (defun tramp-handle-directory-files-and-attributes
2613 (directory &optional full match nosort id-format)
2614 "Like `directory-files-and-attributes' for Tramp files."
2615 (mapcar
2616 (lambda (x)
2617 (cons x (tramp-compat-file-attributes
2618 (if full x (expand-file-name x directory)) id-format)))
2619 (directory-files directory full match nosort)))
2620
2612 (defun tramp-handle-dired-uncache (dir &optional dir-p) 2621 (defun tramp-handle-dired-uncache (dir &optional dir-p)
2613 "Like `dired-uncache' for Tramp files." 2622 "Like `dired-uncache' for Tramp files."
2614 ;; DIR-P is valid for XEmacs only. 2623 ;; DIR-P is valid for XEmacs only.
2615 (with-parsed-tramp-file-name 2624 (with-parsed-tramp-file-name
2616 (if (or dir-p (file-directory-p dir)) dir (file-name-directory dir)) nil 2625 (if (or dir-p (file-directory-p dir)) dir (file-name-directory dir)) nil
2617 (tramp-flush-directory-property v localname))) 2626 (tramp-flush-directory-property v localname)))
2627
2628 (defun tramp-handle-file-exists-p (filename)
2629 "Like `file-exists-p' for Tramp files."
2630 (not (null (file-attributes filename))))
2618 2631
2619 (defun tramp-handle-file-modes (filename) 2632 (defun tramp-handle-file-modes (filename)
2620 "Like `file-modes' for Tramp files." 2633 "Like `file-modes' for Tramp files."
2621 (let ((truename (or (file-truename filename) filename))) 2634 (let ((truename (or (file-truename filename) filename)))
2622 (when (file-exists-p truename) 2635 (when (file-exists-p truename)
2666 2679
2667 (defun tramp-handle-file-name-nondirectory (file) 2680 (defun tramp-handle-file-name-nondirectory (file)
2668 "Like `file-name-nondirectory' but aware of Tramp files." 2681 "Like `file-name-nondirectory' but aware of Tramp files."
2669 (with-parsed-tramp-file-name file nil 2682 (with-parsed-tramp-file-name file nil
2670 (tramp-run-real-handler 'file-name-nondirectory (list localname)))) 2683 (tramp-run-real-handler 'file-name-nondirectory (list localname))))
2684
2685 (defun tramp-handle-file-newer-than-file-p (file1 file2)
2686 "Like `file-newer-than-file-p' for Tramp files."
2687 (cond
2688 ((not (file-exists-p file1)) nil)
2689 ((not (file-exists-p file2)) t)
2690 (t (tramp-time-less-p (nth 5 (file-attributes file2))
2691 (nth 5 (file-attributes file1))))))
2671 2692
2672 (defun tramp-handle-file-regular-p (filename) 2693 (defun tramp-handle-file-regular-p (filename)
2673 "Like `file-regular-p' for Tramp files." 2694 "Like `file-regular-p' for Tramp files."
2674 (and (file-exists-p filename) 2695 (and (file-exists-p filename)
2675 (eq ?- (aref (nth 8 (file-attributes filename)) 0)))) 2696 (eq ?- (aref (nth 8 (file-attributes filename)) 0))))
3549 (let ((time (tramp-time-subtract t1 t2))) 3570 (let ((time (tramp-time-subtract t1 t2)))
3550 (+ (* (car time) 65536.0) 3571 (+ (* (car time) 65536.0)
3551 (cadr time) 3572 (cadr time)
3552 (/ (or (nth 2 time) 0) 1000000.0)))))) 3573 (/ (or (nth 2 time) 0) 1000000.0))))))
3553 3574
3554 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type)
3555 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE.
3556 EOL-TYPE can be one of `dos', `unix', or `mac'."
3557 (cond ((fboundp 'coding-system-change-eol-conversion)
3558 (tramp-compat-funcall
3559 'coding-system-change-eol-conversion coding-system eol-type))
3560 ((fboundp 'subsidiary-coding-system)
3561 (tramp-compat-funcall
3562 'subsidiary-coding-system coding-system
3563 (cond ((eq eol-type 'dos) 'crlf)
3564 ((eq eol-type 'unix) 'lf)
3565 ((eq eol-type 'mac) 'cr)
3566 (t
3567 (error "Unknown EOL-TYPE `%s', must be %s"
3568 eol-type
3569 "`dos', `unix', or `mac'")))))
3570 (t (error "Can't change EOL conversion -- is MULE missing?"))))
3571
3572 (defun tramp-set-process-query-on-exit-flag (process flag)
3573 "Specify if query is needed for process when Emacs is exited.
3574 If the second argument flag is non-nil, Emacs will query the user before
3575 exiting if process is running."
3576 (if (fboundp 'set-process-query-on-exit-flag)
3577 (tramp-compat-funcall 'set-process-query-on-exit-flag process flag)
3578 (tramp-compat-funcall 'process-kill-without-query process flag)))
3579
3580 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' 3575 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
3581 ;; does not deal well with newline characters. Newline is replaced by 3576 ;; does not deal well with newline characters. Newline is replaced by
3582 ;; backslash newline. But if, say, the string `a backslash newline b' 3577 ;; backslash newline. But if, say, the string `a backslash newline b'
3583 ;; is passed to a shell, the shell will expand this into "ab", 3578 ;; is passed to a shell, the shell will expand this into "ab",
3584 ;; completely omitting the newline. This is not what was intended. 3579 ;; completely omitting the newline. This is not what was intended.