emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/net/tramp-smb.el


From: Kai Großjohann
Subject: [Emacs-diffs] Changes to emacs/lisp/net/tramp-smb.el
Date: Fri, 28 Feb 2003 13:28:48 -0500

Index: emacs/lisp/net/tramp-smb.el
diff -c emacs/lisp/net/tramp-smb.el:1.3 emacs/lisp/net/tramp-smb.el:1.4
*** emacs/lisp/net/tramp-smb.el:1.3     Wed Feb  5 16:03:36 2003
--- emacs/lisp/net/tramp-smb.el Fri Feb 28 13:28:47 2003
***************
*** 225,236 ****
        (error "copy-file: file %s already exists" newname))
  
  ;      (with-parsed-tramp-file-name newname nil
!       (let (user host path)
        (with-parsed-tramp-file-name newname l
!         (setq user l-user host l-host path l-path))
        (save-excursion
!         (let ((share (tramp-smb-get-share path))
!               (file (tramp-smb-get-path path t)))
            (unless share
              (error "Target `%s' must contain a share name" filename))
            (tramp-smb-maybe-open-connection user host share)
--- 225,236 ----
        (error "copy-file: file %s already exists" newname))
  
  ;      (with-parsed-tramp-file-name newname nil
!       (let (user host localname)
        (with-parsed-tramp-file-name newname l
!         (setq user l-user host l-host localname l-localname))
        (save-excursion
!         (let ((share (tramp-smb-get-share localname))
!               (file (tramp-smb-get-localname localname t)))
            (unless share
              (error "Target `%s' must contain a share name" filename))
            (tramp-smb-maybe-open-connection user host share)
***************
*** 250,262 ****
    (unless (file-exists-p directory)
      (error "Cannot delete non-existing directory `%s'" directory))
  ;  (with-parsed-tramp-file-name directory nil
!   (let (user host path)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let ((share (tramp-smb-get-share path))
!           (dir (tramp-smb-get-path (file-name-directory path) t))
!           (file (file-name-nondirectory path)))
        (tramp-smb-maybe-open-connection user host share)
        (if (and
             (tramp-smb-send-command user host (format "cd \"%s\"" dir))
--- 250,262 ----
    (unless (file-exists-p directory)
      (error "Cannot delete non-existing directory `%s'" directory))
  ;  (with-parsed-tramp-file-name directory nil
!   (let (user host localname)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let ((share (tramp-smb-get-share localname))
!           (dir (tramp-smb-get-localname (file-name-directory localname) t))
!           (file (file-name-nondirectory localname)))
        (tramp-smb-maybe-open-connection user host share)
        (if (and
             (tramp-smb-send-command user host (format "cd \"%s\"" dir))
***************
*** 273,285 ****
    (unless (file-exists-p filename)
      (error "Cannot delete non-existing file `%s'" filename))
  ;  (with-parsed-tramp-file-name filename nil
!   (let (user host path)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let ((share (tramp-smb-get-share path))
!           (dir (tramp-smb-get-path (file-name-directory path) t))
!           (file (file-name-nondirectory path)))
        (unless (file-exists-p filename)
          (error "Cannot delete non-existing file `%s'" filename))
        (tramp-smb-maybe-open-connection user host share)
--- 273,285 ----
    (unless (file-exists-p filename)
      (error "Cannot delete non-existing file `%s'" filename))
  ;  (with-parsed-tramp-file-name filename nil
!   (let (user host localname)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let ((share (tramp-smb-get-share localname))
!           (dir (tramp-smb-get-localname (file-name-directory localname) t))
!           (file (file-name-nondirectory localname)))
        (unless (file-exists-p filename)
          (error "Cannot delete non-existing file `%s'" filename))
        (tramp-smb-maybe-open-connection user host share)
***************
*** 297,308 ****
    "Like `directory-files' for tramp files."
    (setq directory (directory-file-name (expand-file-name directory)))
  ;  (with-parsed-tramp-file-name directory nil
!   (let (user host path)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let* ((share (tramp-smb-get-share path))
!            (file (tramp-smb-get-path path nil))
             (entries (tramp-smb-get-file-entries user host share file)))
        ;; Just the file names are needed
        (setq entries (mapcar 'car entries))
--- 297,308 ----
    "Like `directory-files' for tramp files."
    (setq directory (directory-file-name (expand-file-name directory)))
  ;  (with-parsed-tramp-file-name directory nil
!   (let (user host localname)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let* ((share (tramp-smb-get-share localname))
!            (file (tramp-smb-get-localname localname nil))
             (entries (tramp-smb-get-file-entries user host share file)))
        ;; Just the file names are needed
        (setq entries (mapcar 'car entries))
***************
*** 312,318 ****
                (delete nil
                        (mapcar (lambda (x) (when (string-match match x) x))
                                entries))))
!       ;; Make absolute paths if necessary
        (when full
          (setq entries
                (mapcar (lambda (x)
--- 312,318 ----
                (delete nil
                        (mapcar (lambda (x) (when (string-match match x) x))
                                entries))))
!       ;; Make absolute localnames if necessary
        (when full
          (setq entries
                (mapcar (lambda (x)
***************
*** 331,348 ****
       (cons x (file-attributes
        (if full x (concat (file-name-as-directory directory) x)))))
     (directory-files directory full match nosort)))
! 
  (defun tramp-smb-handle-file-attributes (filename &optional nonnumeric)
    "Like `file-attributes' for tramp files.
  Optional argument NONNUMERIC means return user and group name
  rather than as numbers."
  ;  (with-parsed-tramp-file-name filename nil
!   (let (user host path)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let* ((share (tramp-smb-get-share path))
!            (file (tramp-smb-get-path path nil))
             (entries (tramp-smb-get-file-entries user host share file))
             (entry (and entries
                         (assoc (file-name-nondirectory file) entries)))
--- 331,348 ----
       (cons x (file-attributes
        (if full x (concat (file-name-as-directory directory) x)))))
     (directory-files directory full match nosort)))
!  
  (defun tramp-smb-handle-file-attributes (filename &optional nonnumeric)
    "Like `file-attributes' for tramp files.
  Optional argument NONNUMERIC means return user and group name
  rather than as numbers."
  ;  (with-parsed-tramp-file-name filename nil
!   (let (user host localname)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let* ((share (tramp-smb-get-share localname))
!            (file (tramp-smb-get-localname localname nil))
             (entries (tramp-smb-get-file-entries user host share file))
             (entry (and entries
                         (assoc (file-name-nondirectory file) entries)))
***************
*** 368,379 ****
  (defun tramp-smb-handle-file-directory-p (filename)
    "Like `file-directory-p' for tramp files."
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host path)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let* ((share (tramp-smb-get-share path))
!            (file (tramp-smb-get-path path nil))
             (entries (tramp-smb-get-file-entries user host share file))
             (entry (and entries
                         (assoc (file-name-nondirectory file) entries))))
--- 368,379 ----
  (defun tramp-smb-handle-file-directory-p (filename)
    "Like `file-directory-p' for tramp files."
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host localname)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let* ((share (tramp-smb-get-share localname))
!            (file (tramp-smb-get-localname localname nil))
             (entries (tramp-smb-get-file-entries user host share file))
             (entry (and entries
                         (assoc (file-name-nondirectory file) entries))))
***************
*** 384,395 ****
  (defun tramp-smb-handle-file-exists-p (filename)
    "Like `file-exists-p' for tramp files."
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host path)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let* ((share (tramp-smb-get-share path))
!            (file (tramp-smb-get-path path nil))
             (entries (tramp-smb-get-file-entries user host share file)))
        (and entries
             (member (file-name-nondirectory file) (mapcar 'car entries))
--- 384,395 ----
  (defun tramp-smb-handle-file-exists-p (filename)
    "Like `file-exists-p' for tramp files."
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host localname)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let* ((share (tramp-smb-get-share localname))
!            (file (tramp-smb-get-localname localname nil))
             (entries (tramp-smb-get-file-entries user host share file)))
        (and entries
             (member (file-name-nondirectory file) (mapcar 'car entries))
***************
*** 399,406 ****
    "Like `file-local-copy' for tramp files."
    (with-parsed-tramp-file-name filename nil
      (save-excursion
!       (let ((share (tramp-smb-get-share path))
!           (file (tramp-smb-get-path path t))
            (tmpfil (tramp-make-temp-file)))
        (unless (file-exists-p filename)
          (error "Cannot make local copy of non-existing file `%s'" filename))
--- 399,406 ----
    "Like `file-local-copy' for tramp files."
    (with-parsed-tramp-file-name filename nil
      (save-excursion
!       (let ((share (tramp-smb-get-share localname))
!           (file (tramp-smb-get-localname localname t))
            (tmpfil (tramp-make-temp-file)))
        (unless (file-exists-p filename)
          (error "Cannot make local copy of non-existing file `%s'" filename))
***************
*** 421,433 ****
  (defun tramp-smb-handle-file-name-all-completions (filename directory)
    "Like `file-name-all-completions' for tramp files."
  ;  (with-parsed-tramp-file-name directory nil
!   (let (user host path)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host path l-path))
      (save-match-data
        (save-excursion
!       (let* ((share (tramp-smb-get-share path))
!              (file (tramp-smb-get-path path nil))
               (entries (tramp-smb-get-file-entries user host share file)))
  
          (all-completions
--- 421,433 ----
  (defun tramp-smb-handle-file-name-all-completions (filename directory)
    "Like `file-name-all-completions' for tramp files."
  ;  (with-parsed-tramp-file-name directory nil
!   (let (user host localname)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host localname l-localname))
      (save-match-data
        (save-excursion
!       (let* ((share (tramp-smb-get-share localname))
!              (file (tramp-smb-get-localname localname nil))
               (entries (tramp-smb-get-file-entries user host share file)))
  
          (all-completions
***************
*** 451,462 ****
  (defun tramp-smb-handle-file-writable-p (filename)
    "Like `file-writable-p' for tramp files."
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host path)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let* ((share (tramp-smb-get-share path))
!            (file (tramp-smb-get-path path nil))
             (entries (tramp-smb-get-file-entries user host share file))
             (entry (and entries
                         (assoc (file-name-nondirectory file) entries))))
--- 451,462 ----
  (defun tramp-smb-handle-file-writable-p (filename)
    "Like `file-writable-p' for tramp files."
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host localname)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let* ((share (tramp-smb-get-share localname))
!            (file (tramp-smb-get-localname localname nil))
             (entries (tramp-smb-get-file-entries user host share file))
             (entry (and entries
                         (assoc (file-name-nondirectory file) entries))))
***************
*** 474,489 ****
      ;; this function is called with a non-directory ...
      (setq filename (file-name-as-directory filename)))
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host path)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host path l-path))
      (save-match-data
!       (let* ((share (tramp-smb-get-share path))
!            (file (tramp-smb-get-path path nil))
             (entries (tramp-smb-get-file-entries user host share file)))
  
        ;; Delete dummy "" entry, useless entries
!       (setq entries
              (if (file-directory-p filename)
                  (delq (assoc "" entries) entries)
                ;; We just need the only and only entry FILENAME.
--- 474,489 ----
      ;; this function is called with a non-directory ...
      (setq filename (file-name-as-directory filename)))
  ;  (with-parsed-tramp-file-name filename nil
!   (let        (user host localname)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host localname l-localname))
      (save-match-data
!       (let* ((share (tramp-smb-get-share localname))
!            (file (tramp-smb-get-localname localname nil))
             (entries (tramp-smb-get-file-entries user host share file)))
  
        ;; Delete dummy "" entry, useless entries
!       (setq entries 
              (if (file-directory-p filename)
                  (delq (assoc "" entries) entries)
                ;; We just need the only and only entry FILENAME.
***************
*** 527,537 ****
    (unless (file-name-absolute-p dir)
      (setq dir (concat default-directory dir)))
  ;  (with-parsed-tramp-file-name dir nil
!   (let        (user host path)
      (with-parsed-tramp-file-name dir l
!       (setq user l-user host l-host path l-path))
      (save-match-data
!       (let* ((share (tramp-smb-get-share path))
             (ldir (file-name-directory dir)))
        ;; Make missing directory parts
        (when (and parents share (not (file-directory-p ldir)))
--- 527,537 ----
    (unless (file-name-absolute-p dir)
      (setq dir (concat default-directory dir)))
  ;  (with-parsed-tramp-file-name dir nil
!   (let        (user host localname)
      (with-parsed-tramp-file-name dir l
!       (setq user l-user host l-host localname l-localname))
      (save-match-data
!       (let* ((share (tramp-smb-get-share localname))
             (ldir (file-name-directory dir)))
        ;; Make missing directory parts
        (when (and parents share (not (file-directory-p ldir)))
***************
*** 548,559 ****
    (unless (file-name-absolute-p directory)
      (setq ldir (concat default-directory directory)))
  ;  (with-parsed-tramp-file-name directory nil
!   (let        (user host path)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host path l-path))
      (save-match-data
!       (let* ((share (tramp-smb-get-share path))
!            (file (tramp-smb-get-path path nil)))
        (when (file-directory-p (file-name-directory directory))
          (tramp-smb-maybe-open-connection user host share)
          (tramp-smb-send-command user host (format "mkdir \"%s\"" file)))
--- 548,559 ----
    (unless (file-name-absolute-p directory)
      (setq ldir (concat default-directory directory)))
  ;  (with-parsed-tramp-file-name directory nil
!   (let        (user host localname)
      (with-parsed-tramp-file-name directory l
!       (setq user l-user host l-host localname l-localname))
      (save-match-data
!       (let* ((share (tramp-smb-get-share localname))
!            (file (tramp-smb-get-localname localname nil)))
        (when (file-directory-p (file-name-directory directory))
          (tramp-smb-maybe-open-connection user host share)
          (tramp-smb-send-command user host (format "mkdir \"%s\"" file)))
***************
*** 581,592 ****
          (error "rename-file: file %s already exists" newname))
  
  ;      (with-parsed-tramp-file-name newname nil
!       (let (user host path)
        (with-parsed-tramp-file-name newname l
!         (setq user l-user host l-host path l-path))
        (save-excursion
!         (let ((share (tramp-smb-get-share path))
!               (file (tramp-smb-get-path path t)))
            (tramp-smb-maybe-open-connection user host share)
            (tramp-message-for-buffer
             nil tramp-smb-method user host
--- 581,592 ----
          (error "rename-file: file %s already exists" newname))
  
  ;      (with-parsed-tramp-file-name newname nil
!       (let (user host localname)
        (with-parsed-tramp-file-name newname l
!         (setq user l-user host l-host localname l-localname))
        (save-excursion
!         (let ((share (tramp-smb-get-share localname))
!               (file (tramp-smb-get-localname localname t)))
            (tramp-smb-maybe-open-connection user host share)
            (tramp-message-for-buffer
             nil tramp-smb-method user host
***************
*** 613,624 ****
                                filename))
        (error "File not overwritten")))
  ;  (with-parsed-tramp-file-name filename nil
!   (let (user host path)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host path l-path))
      (save-excursion
!       (let ((share (tramp-smb-get-share path))
!           (file (tramp-smb-get-path path t))
            (curbuf (current-buffer))
            ;; We use this to save the value of `last-coding-system-used'
            ;; after writing the tmp file.  At the end of the function,
--- 613,624 ----
                                filename))
        (error "File not overwritten")))
  ;  (with-parsed-tramp-file-name filename nil
!   (let (user host localname)
      (with-parsed-tramp-file-name filename l
!       (setq user l-user host l-host localname l-localname))
      (save-excursion
!       (let ((share (tramp-smb-get-share localname))
!           (file (tramp-smb-get-localname localname t))
            (curbuf (current-buffer))
            ;; We use this to save the value of `last-coding-system-used'
            ;; after writing the tmp file.  At the end of the function,
***************
*** 666,682 ****
  
  ;; Internal file name functions
  
! (defun tramp-smb-get-share (path)
!   "Returns the share name of PATH."
    (save-match-data
!     (when (string-match "^/?\\([^/]+\\)/" path)
!       (match-string 1 path))))
  
! (defun tramp-smb-get-path (path convert)
!   "Returns the file name of PATH.
  If CONVERT is non-nil exchange \"/\" by \"\\\\\"."
    (save-match-data
!     (let ((res path))
  
        (setq
         res (if (string-match "^/?[^/]+/\\(.*\\)" res)
--- 666,682 ----
  
  ;; Internal file name functions
  
! (defun tramp-smb-get-share (localname)
!   "Returns the share name of LOCALNAME."
    (save-match-data
!     (when (string-match "^/?\\([^/]+\\)/" localname)
!       (match-string 1 localname))))
  
! (defun tramp-smb-get-localname (localname convert)
!   "Returns the file name of LOCALNAME.
  If CONVERT is non-nil exchange \"/\" by \"\\\\\"."
    (save-match-data
!     (let ((res localname))
  
        (setq
         res (if (string-match "^/?[^/]+/\\(.*\\)" res)
***************
*** 697,712 ****
  
  ;; Share names of a host are cached. It is very unlikely that the
  ;; shares do change during connection.
! (defun tramp-smb-get-file-entries (user host share path)
!   "Read entries which match PATH.
  Either the shares are listed, or the `dir' command is executed.
! Only entries matching the path are returned.
! Result is a list of (PATH MODE SIZE MONTH DAY TIME YEAR)."
    (save-excursion
      (save-match-data
!       (let ((base (or (and (> (length path) 0)
!                          (string-match "\\([^/]+\\)$" path)
!                          (regexp-quote (match-string 1 path)))
                      ""))
            res entry)
        (set-buffer (tramp-get-buffer nil tramp-smb-method user host))
--- 697,712 ----
  
  ;; Share names of a host are cached. It is very unlikely that the
  ;; shares do change during connection.
! (defun tramp-smb-get-file-entries (user host share localname)
!   "Read entries which match LOCALNAME.
  Either the shares are listed, or the `dir' command is executed.
! Only entries matching the localname are returned.
! Result is a list of (LOCALNAME MODE SIZE MONTH DAY TIME YEAR)."
    (save-excursion
      (save-match-data
!       (let ((base (or (and (> (length localname) 0)
!                          (string-match "\\([^/]+\\)$" localname)
!                          (regexp-quote (match-string 1 localname)))
                      ""))
            res entry)
        (set-buffer (tramp-get-buffer nil tramp-smb-method user host))
***************
*** 719,725 ****
            (tramp-smb-send-command
             user host
             (format "dir %s"
!                    (if (zerop (length path)) "" (concat "\"" path "*\"")))))
          (goto-char (point-min))
          ;; Loop the listing
          (unless (re-search-forward tramp-smb-errors nil t)
--- 719,725 ----
            (tramp-smb-send-command
             user host
             (format "dir %s"
!                    (if (zerop (length localname)) "" (concat "\"" localname 
"*\"")))))
          (goto-char (point-min))
          ;; Loop the listing
          (unless (re-search-forward tramp-smb-errors nil t)
***************
*** 780,794 ****
  (defun tramp-smb-read-file-entry (share)
    "Parse entry in SMB output buffer.
  If SHARE is result, entries are of type dir. Otherwise, shares are listed.
! Result is the list (PATH MODE SIZE MTIME)."
    (let ((line (buffer-substring (point) (tramp-point-at-eol)))
!       path mode size month day hour min sec year mtime)
  
      (if (not share)
  
        ; Read share entries
        (when (string-match "^\\s-+\\(\\S-+\\)\\s-+Disk" line)
!         (setq path (match-string 1 line)
                mode "dr-xr-xr-x"
                size 0))
  
--- 780,794 ----
  (defun tramp-smb-read-file-entry (share)
    "Parse entry in SMB output buffer.
  If SHARE is result, entries are of type dir. Otherwise, shares are listed.
! Result is the list (LOCALNAME MODE SIZE MTIME)."
    (let ((line (buffer-substring (point) (tramp-point-at-eol)))
!       localname mode size month day hour min sec year mtime)
  
      (if (not share)
  
        ; Read share entries
        (when (string-match "^\\s-+\\(\\S-+\\)\\s-+Disk" line)
!         (setq localname (match-string 1 line)
                mode "dr-xr-xr-x"
                size 0))
  
***************
*** 847,858 ****
             line (substring line 0 (- (1+ (length (match-string 2 line))))))
          (return))
  
!       ;; path
        (if (string-match "^\\s-+\\(\\S-\\(.*\\S-\\)?\\)\\s-+$" line)
!           (setq path (match-string 1 line))
          (return))))
  
!     (when (and path mode size)
        (setq mtime
            (if (and sec min hour day month year)
                (encode-time
--- 847,858 ----
             line (substring line 0 (- (1+ (length (match-string 2 line))))))
          (return))
  
!       ;; localname
        (if (string-match "^\\s-+\\(\\S-\\(.*\\S-\\)?\\)\\s-+$" line)
!           (setq localname (match-string 1 line))
          (return))))
  
!     (when (and localname mode size)
        (setq mtime
            (if (and sec min hour day month year)
                (encode-time
***************
*** 860,866 ****
                 (cdr (assoc (downcase month) tramp-smb-parse-time-months))
                 year)
              '(0 0)))
!       (list path mode size mtime))))
  
  ;; Inodes don't exist for SMB files.  Therefore we must generate virtual ones.
  ;; Used in `find-buffer-visiting'.
--- 860,866 ----
                 (cdr (assoc (downcase month) tramp-smb-parse-time-months))
                 year)
              '(0 0)))
!       (list localname mode size mtime))))
  
  ;; Inodes don't exist for SMB files.  Therefore we must generate virtual ones.
  ;; Used in `find-buffer-visiting'.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]