/[tramp]/tramp/lisp/tramp.el
ViewVC logotype

Diff of /tramp/lisp/tramp.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.243 by kai, Mon Oct 14 15:03:33 2002 UTC revision 2.244 by albinus, Mon Oct 14 20:39:22 2002 UTC
# Line 3276  pass to the OPERATION." Line 3276  pass to the OPERATION."
3276           (inhibit-file-name-operation operation))           (inhibit-file-name-operation operation))
3277      (apply operation args)))      (apply operation args)))
3278    
3279  ;; We handle here primitives who don't pass the file name as first parameter.  ;; We handle here all file primitives.  Most of them have the file
3280  ;; Future primitives are expected to have the file name as first parameter.  ;; name as first parameter; nevertheless we check for them explicitly
3281  ;; This scenario is needed because there isn't a way to decide by syntactical  ;; in order to be be signalled if a new primitive appears.  This
3282  ;; means whether a foreign method must be called. It would ease the live  ;; scenario is needed because there isn't a way to decide by
3283  ;; if `file-name-handler-alist' would support a decision function as well but  ;; syntactical means whether a foreign method must be called.  It would
3284  ;; regexp only.  ;; ease the live if `file-name-handler-alist' would support a decision
3285  (defun tramp-primitive-file-name (operation &rest args)  ;; function as well but regexp only.
3286    "Return file name related to OPERATION primitive."  (defun tramp-file-name-for-operation (operation &rest args)
3287      "Return file name related to OPERATION file primitive.
3288    ARGS are the arguments OPERATION has been called with."
3289    (cond    (cond
3290       ; FILE resp DIRECTORY
3291       ((member operation
3292                (list 'delete-directory 'delete-file 'diff-latest-backup-file
3293                      'directory-file-name 'directory-files 'dired-compress-file
3294                      'dired-uncache 'file-accessible-directory-p 'file-attributes
3295                      'substitute-in-file-name 'file-directory-p
3296                      'file-executable-p 'file-exists-p 'file-local-copy
3297                      'file-modes 'file-name-as-directory 'file-name-directory
3298                      'file-name-nondirectory 'file-name-sans-versions
3299                      'file-ownership-preserved-p 'file-readable-p 'file-regular-p
3300                      'file-symlink-p 'file-truename 'file-writable-p
3301                      'find-backup-file-name 'get-file-buffer 'insert-directory
3302                      'insert-file-contents 'load 'make-directory 'set-file-modes
3303                      'unhandled-file-name-directory 'vc-registered
3304                      ; XEmacs
3305                      'abbreviate-file-name 'create-file-buffer
3306                      'dired-set-file-modtime 'backup-buffer
3307                      ; uncocumented primitives
3308                      'byte-compiler-base-file-name))
3309        (nth 0 args))
3310     ; FILE DIRECTORY resp FILE1 FILE2     ; FILE DIRECTORY resp FILE1 FILE2
3311     ((member operation     ((member operation
3312              (list 'add-name-to-file 'copy-file 'expand-file-name              (list 'add-name-to-file 'copy-file 'expand-file-name
# Line 3305  pass to the OPERATION." Line 3327  pass to the OPERATION."
3327     ((member operation (list 'dired-call-process 'shell-command))     ((member operation (list 'dired-call-process 'shell-command))
3328      default-directory)      default-directory)
3329     ; FILE     ; FILE
3330     ((stringp (nth 0 args))     (t (error "unknown file I/O primitive: %s" operation))))
     (nth 0 args))))  
3331    
3332  ;; Main function.  ;; Main function.
3333  ;;;###autoload  ;;;###autoload
3334  (defun tramp-file-name-handler (operation &rest args)  (defun tramp-file-name-handler (operation &rest args)
3335    "Invoke tramp file name handler.    "Invoke tramp file name handler.
3336  Falls back to normal file name handler if no tramp file name handler exists."  Falls back to normal file name handler if no tramp file name handler exists."
3337    (let ((fn (assoc operation tramp-file-name-handler-alist))    (save-match-data
3338          (filename (apply 'tramp-primitive-file-name operation args)))      (let ((fn (assoc operation tramp-file-name-handler-alist))
3339      (cond            (filename (apply 'tramp-file-name-for-operation operation args)))
3340       ((and tramp-unified-filenames fn (tramp-ftp-file-name-p filename))        (cond
3341        (apply 'tramp-ftp-file-name-handler operation args))         ((and tramp-unified-filenames fn (tramp-ftp-file-name-p filename))
3342       (fn (save-match-data (apply (cdr fn) args)))          (apply 'tramp-ftp-file-name-handler operation args))
3343       (t (tramp-run-real-handler operation args)))))         (fn (apply (cdr fn) args))
3344           (t (tramp-run-real-handler operation args))))))
3345    
3346  (put 'tramp-file-name-handler 'file-remote-p t) ;for file-remote-p  (put 'tramp-file-name-handler 'file-remote-p t) ;for file-remote-p
3347    
# Line 5639  Not actually used.  Use `(format \"%o\" Line 5661  Not actually used.  Use `(format \"%o\"
5661    "Return an `tramp-file-name' structure.    "Return an `tramp-file-name' structure.
5662  The structure consists of remote method, remote user, remote host and  The structure consists of remote method, remote user, remote host and
5663  remote path name."  remote path name."
5664    (let (method)    (save-match-data
5665      (save-match-data      (let* ((match (string-match (nth 0 tramp-file-name-structure) name))
5666        (unless (string-match (nth 0 tramp-file-name-structure) name)             (method
5667          (error "Not a tramp file name: %s" name))              ; single-hop
5668        (setq method (match-string (nth 1 tramp-file-name-structure) name))              (if match (match-string (nth 1 tramp-file-name-structure) name)
5669                  ; maybe multi-hop
5670                  (string-match
5671                   (format (nth 0 tramp-multi-file-name-structure)
5672                           (nth 0 tramp-multi-file-name-hop-structure)) name)
5673                  (match-string (nth 1 tramp-multi-file-name-structure) name))))
5674        (if (and method (member method tramp-multi-methods))        (if (and method (member method tramp-multi-methods))
5675            ;; If it's a multi method, the file name structure contains            ;; If it's a multi method, the file name structure contains
5676            ;; arrays of method, user and host.            ;; arrays of method, user and host.
5677            (tramp-dissect-multi-file-name name)            (tramp-dissect-multi-file-name name)
5678          ;; Normal method.  First, find out default method.          ;; Normal method.  First, find out default method.
5679            (unless match (error "Not a tramp file name: %s" name))
5680          (let ((user (match-string (nth 2 tramp-file-name-structure) name))          (let ((user (match-string (nth 2 tramp-file-name-structure) name))
5681                (host (match-string (nth 3 tramp-file-name-structure) name))                (host (match-string (nth 3 tramp-file-name-structure) name))
5682                (path (match-string (nth 4 tramp-file-name-structure) name)))                (path (match-string (nth 4 tramp-file-name-structure) name)))

Legend:
Removed from v.2.243  
changed lines
  Added in v.2.244

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26