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

Diff of /tramp/lisp/tramp-smb.el

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

revision 2.5 by albinus, Tue Nov 5 22:32:44 2002 UTC revision 2.6 by albinus, Sun Nov 10 19:43:57 2002 UTC
# Line 71  Change it only if you know what you do." Line 71  Change it only if you know what you do."
71     'identity     'identity
72     '(     '(
73       ; Samba       ; Samba
74       "ERRSRV" "ERRDOS" "ERRbadpw" "ERRnoaccess"       "ERRSRV" "ERRDOS" "ERRbadpw" "ERRnoaccess" "ERRnosuchshare"
75       ; Windows NT 4.0       ; Windows NT 4.0
76       "NT_STATUS_BAD_NETWORK_NAME"       "NT_STATUS_BAD_NETWORK_NAME"
77       "NT_STATUS_CANNOT_DELETE"       "NT_STATUS_CANNOT_DELETE"
# Line 94  This variable is local to each buffer.") Line 94  This variable is local to each buffer.")
94      ;; `access-file' performed by default handler      ;; `access-file' performed by default handler
95      (add-name-to-file . tramp-smb-not-handled)      (add-name-to-file . tramp-smb-not-handled)
96      ;; `byte-compiler-base-file-name' performed by default handler      ;; `byte-compiler-base-file-name' performed by default handler
97      (copy-file . tramp-smb-not-handled)      (copy-file . tramp-smb-handle-copy-file)
98      (delete-directory . tramp-smb-not-handled)      (delete-directory . tramp-smb-not-handled-yet)
99      (delete-file . tramp-smb-handle-delete-file)      (delete-file . tramp-smb-handle-delete-file)
100      (diff-latest-backup-file . tramp-smb-not-handled)      ;; `diff-latest-backup-file' performed by default handler
101      ;; `directory-file-name' performed by default handler      ;; `directory-file-name' performed by default handler
102      (directory-files . tramp-smb-not-handled)      (directory-files . tramp-smb-not-handled-yet)
103      (directory-files-and-attributes . tramp-smb-not-handled)      (directory-files-and-attributes . tramp-smb-not-handled-yet)
104      (dired-call-process . tramp-smb-not-handled)      (dired-call-process . tramp-smb-not-handled)
105      (dired-compress-file . tramp-smb-not-handled)      (dired-compress-file . tramp-smb-not-handled)
106      ;; `dired-uncache' performed by default handler      ;; `dired-uncache' performed by default handler
# Line 111  This variable is local to each buffer.") Line 111  This variable is local to each buffer.")
111      (file-executable-p . tramp-smb-handle-file-exists-p)      (file-executable-p . tramp-smb-handle-file-exists-p)
112      (file-exists-p . tramp-smb-handle-file-exists-p)      (file-exists-p . tramp-smb-handle-file-exists-p)
113      (file-local-copy . tramp-smb-handle-file-local-copy)      (file-local-copy . tramp-smb-handle-file-local-copy)
114      (file-modes . tramp-smb-not-handled)      (file-modes . tramp-smb-not-handled-yet)
115      (file-name-all-completions . tramp-smb-not-handled)      (file-name-all-completions . tramp-smb-handle-file-name-all-completions)
116      ;; `file-name-as-directory' performed by default handler      ;; `file-name-as-directory' performed by default handler
117      (file-name-completion . tramp-smb-not-handled)      (file-name-completion . tramp-handle-file-name-completion)
118      (file-name-directory . tramp-handle-file-name-directory)      (file-name-directory . tramp-handle-file-name-directory)
119      (file-name-nondirectory . tramp-handle-file-name-nondirectory)      (file-name-nondirectory . tramp-handle-file-name-nondirectory)
120      ;; `file-name-sans-versions' performed by default handler      ;; `file-name-sans-versions' performed by default handler
121      (file-newer-than-file-p . tramp-smb-not-handled)      (file-newer-than-file-p . tramp-smb-handle-file-newer-than-file-p)
122      (file-ownership-preserved-p . tramp-smb-not-handled)      (file-ownership-preserved-p . tramp-smb-not-handled)
123      (file-readable-p . tramp-smb-handle-file-exists-p)      (file-readable-p . tramp-smb-handle-file-exists-p)
124      (file-regular-p . tramp-smb-not-handled)      (file-regular-p . tramp-handle-file-regular-p)
125      (file-symlink-p . tramp-smb-handle-file-symlink-p)      (file-symlink-p . tramp-smb-not-handled)
126      ;; `file-truename' performed by default handler      ;; `file-truename' performed by default handler
127      (file-writable-p . tramp-smb-handle-file-writable-p)      (file-writable-p . tramp-smb-handle-file-writable-p)
128      (find-backup-file-name . tramp-smb-not-handled)      ;; `find-backup-file-name' performed by default handler
129      (find-file-noselect . tramp-smb-not-handled)      ;; `find-file-noselect' performed by default handler
130      ;; `get-file-buffer' performed by default handler      ;; `get-file-buffer' performed by default handler
131      (insert-directory . tramp-smb-handle-insert-directory)      (insert-directory . tramp-smb-handle-insert-directory)
132      (insert-file-contents . tramp-handle-insert-file-contents)      (insert-file-contents . tramp-handle-insert-file-contents)
133      (load . tramp-smb-not-handled)      (load . tramp-handle-load)
134      (make-directory . tramp-smb-not-handled)      (make-directory . tramp-smb-not-handled-yet)
135      (make-directory-internal . tramp-smb-not-handled)      (make-directory-internal . tramp-smb-not-handled-yet)
136      (make-symbolic-link . tramp-smb-not-handled)      (make-symbolic-link . tramp-smb-not-handled)
137      (rename-file . tramp-smb-not-handled)      (rename-file . tramp-smb-handle-rename-file)
138      (set-file-modes . tramp-smb-not-handled)      (set-file-modes . tramp-smb-not-handled-yet)
139      (set-visited-file-modtime . tramp-smb-handle-set-visited-file-modtime)      (set-visited-file-modtime . tramp-smb-not-handled)
140      (shell-command . tramp-smb-not-handled)      (shell-command . tramp-smb-not-handled)
141      ;; `substitute-in-file-name' performed by default handler      (substitute-in-file-name . tramp-smb-handle-substitute-in-file-name)
142      (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)      (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
143      ;; `vc-registered' performed by default handler      ;; `vc-registered' performed by default handler
144      (verify-visited-file-modtime . tramp-smb-handle-verify-visited-file-modtime)      (verify-visited-file-modtime . tramp-smb-not-handled)
145      (write-region . tramp-smb-not-handled)      (write-region . tramp-smb-handle-write-region)
146  )  )
147    "Alist of handler functions for Tramp SMB method.    "Alist of handler functions for Tramp SMB method.
148  Operations not mentioned here will be handled by the default Emacs primitives.")  Operations not mentioned here will be handled by the default Emacs primitives.")
# Line 164  First arg specifies the OPERATION, secon Line 164  First arg specifies the OPERATION, secon
164  pass to the OPERATION."  pass to the OPERATION."
165    (let ((fn (assoc operation tramp-smb-file-name-handler-alist)))    (let ((fn (assoc operation tramp-smb-file-name-handler-alist)))
166      (if fn      (if fn
167          (if (equal (cdr fn) 'tramp-smb-not-handled)          (if (memq (cdr fn)
168                      (list 'tramp-smb-not-handled 'tramp-smb-not-handled-yet))
169              (apply (cdr fn) operation args)              (apply (cdr fn) operation args)
170            (save-match-data (apply (cdr fn) args)))            (save-match-data (apply (cdr fn) args)))
171        (tramp-run-real-handler operation args))))        (tramp-run-real-handler operation args))))
# Line 173  pass to the OPERATION." Line 174  pass to the OPERATION."
174    (add-to-list 'tramp-foreign-file-name-handler-alist    (add-to-list 'tramp-foreign-file-name-handler-alist
175                 (cons 'tramp-smb-file-name-p 'tramp-smb-file-name-handler)))                 (cons 'tramp-smb-file-name-p 'tramp-smb-file-name-handler)))
176    
177    
178  ;; File name primitives  ;; File name primitives
179    
180  (defun tramp-smb-not-handled (operation &rest args)  (defun tramp-smb-not-handled (operation &rest args)
181      "Default handler for all functions which are disrecarded."
182      (tramp-message 10 "Won't be handled: %s %s" operation args)
183      nil)
184    
185    (defun tramp-smb-not-handled-yet (operation &rest args)
186    "Default handler for all functions.    "Default handler for all functions.
187  Used during development in order to get an impression what's left to do."  Used during development in order to get an impression what's left to do."
188    (tramp-message 1 "Not handled yet: %s %s" operation args)    (tramp-message 1 "Not handled yet: %s %s" operation args)
189    (tramp-run-real-handler operation args))    (tramp-run-real-handler operation args))
190    
191    (defun tramp-smb-handle-copy-file
192      (filename newname &optional ok-if-already-exists keep-date)
193      "Like `copy-file' for tramp files.
194    KEEP-DATE is not handled in case NEWNAME resides on an SMB server."
195      (setq filename (expand-file-name filename)
196            newname (expand-file-name newname))
197    
198      (let ((tmpfile (file-local-copy filename)))
199    
200        (if tmpfile
201            ;; remote filename
202            (rename-file tmpfile newname ok-if-already-exists)
203    
204          ;; remote newname
205          (when (file-directory-p newname)
206            (setq newname (expand-file-name
207                          (file-name-nondirectory filename) newname)))
208          (when (and (not ok-if-already-exists)
209                     (file-exists-p newname))
210              (error "copy-file: file %s already exists" newname))
211    
212    ;      (with-parsed-tramp-file-name newname nil
213          (let (user host path)
214            (with-parsed-tramp-file-name newname l
215              (setq user l-user host l-host path l-path))
216            (save-excursion
217              (let ((share (tramp-smb-get-share path))
218                    (file  (tramp-smb-get-path  path t)))
219                (tramp-smb-maybe-open-connection user host share)
220                (tramp-message-for-buffer
221                 nil tramp-smb-method user host
222                 5 "Copying file %s to file %s..." filename newname)
223                (tramp-smb-send-command user host (format "put %s \"%s\"" filename file))
224                (tramp-message-for-buffer
225                 nil tramp-smb-method user host
226                 5 "Copying file %s to file %s...done" filename newname)))))))
227    
228  (defun tramp-smb-handle-delete-file (filename)  (defun tramp-smb-handle-delete-file (filename)
229    "Like `delete-file' for tramp files."    "Like `delete-file' for tramp files."
230    (setq filename (expand-file-name filename))    (setq filename (expand-file-name filename))
231  ;  (with-parsed-tramp-file-name filename nil  ;  (with-parsed-tramp-file-name filename nil
232    (let (user host share)    (let (user host path)
233      (with-parsed-tramp-file-name filename l      (with-parsed-tramp-file-name filename l
234        (setq user l-user host l-host path l-path))        (setq user l-user host l-host path l-path))
235      (save-excursion      (save-excursion
# Line 264  rather than as numbers." Line 308  rather than as numbers."
308           5 "Fetching %s to tmp file %s...done" filename tmpfil)           5 "Fetching %s to tmp file %s...done" filename tmpfil)
309          tmpfil))))          tmpfil))))
310    
311  (defun tramp-smb-handle-file-symlink-p (filename)  ;; This function should return "foo/" for directories and "bar" for
312    "Like `file-symlink-p' for tramp files."  ;; files.
313    nil)  (defun tramp-smb-handle-file-name-all-completions (filename directory)
314      "Like `file-name-all-completions' for tramp files."
315    ;  (with-parsed-tramp-file-name directory nil
316      (let  (user host path res entry)
317        (with-parsed-tramp-file-name directory l
318          (setq user l-user host l-host path l-path))
319        (save-match-data
320          (save-excursion
321            (if (equal path "/")
322    
323                ;; Share to be completed
324                (progn
325                  (tramp-message-for-buffer
326                   nil tramp-smb-method user host 10
327                   "Looking for shares on host %s" host)
328                  (setq res (tramp-smb-check-shares user host)))
329    
330              ;; Real file to be completed
331              (let* ((share (tramp-smb-get-share path))
332                     (file  (tramp-smb-get-path  path t)))
333                (tramp-message-for-buffer
334                 nil tramp-smb-method user host 10
335                 "Grabbing directory `dir \"%s*\"'" path)
336                (tramp-smb-maybe-open-connection user host share)
337                (tramp-smb-send-command user host (format "dir \"%s*\"" file))
338    
339                ;; Read entries
340                (set-buffer (tramp-get-buffer nil tramp-smb-method user host))
341                (beginning-of-buffer)
342                (while (setq entry (tramp-smb-read-file-entry))
343                  (add-to-list
344                   'res (list
345                         (format
346                          "%s%s"
347                          (nth 0 entry)
348                          (if (string-match "d" (nth 1 entry)) "/" ""))))
349                  (forward-line))))
350    
351            ;; Return the list.
352            (all-completions filename res)))))
353    
354    (defun tramp-smb-handle-file-newer-than-file-p (file1 file2)
355      "Like `file-newer-than-file-p' for tramp files."
356      (cond
357       ((not (file-exists-p file1)) nil)
358       ((not (file-exists-p file2)) t)
359       (t
360        (save-excursion
361          (let ((fa1 (file-attributes file1))
362                (fa2 (file-attributes file2)))
363            (when (and (not (equal (nth 5 fa1) '(0 0)))
364                       (not (equal (nth 5 fa2) '(0 0))))
365              (> 0 (car (tramp-time-diff (nth 5 fa1) (nth 5 fa2))))))))))
366    
367  (defun tramp-smb-handle-file-writable-p (filename)  (defun tramp-smb-handle-file-writable-p (filename)
368    "Like `file-writable-p' for tramp files."    "Like `file-writable-p' for tramp files."
# Line 284  rather than as numbers." Line 380  rather than as numbers."
380  SWITCHES, WILDCARD and FULL-DIRECTORY-P are not handled."  SWITCHES, WILDCARD and FULL-DIRECTORY-P are not handled."
381    (setq filename (expand-file-name filename))    (setq filename (expand-file-name filename))
382  ;  (with-parsed-tramp-file-name filename nil  ;  (with-parsed-tramp-file-name filename nil
383    (let (user host share)    (let  ((dirp (file-directory-p filename))
384             user host path)
385      (with-parsed-tramp-file-name filename l      (with-parsed-tramp-file-name filename l
386        (setq user l-user host l-host path l-path))        (setq user l-user host l-host path l-path))
387      (save-match-data      (save-match-data
388        (save-excursion        (save-excursion
389          (let* ((share (tramp-smb-get-share path))          (let* ((share (tramp-smb-get-share path))
390                 (file  (tramp-smb-get-path  path t)))                 (file  (tramp-smb-get-path  path t)))
391              (when dirp
392                ;; This check is a little bit strange, but in `dired-add-entry'
393                ;; this function is called with a non-direcory ...
394                (setq file (concat file "*")))
395            (tramp-message-for-buffer            (tramp-message-for-buffer
396             nil tramp-smb-method user host 10             nil tramp-smb-method user host 10
397             "Inserting directory `dir \"%s*\"'" path)             "Inserting directory `dir \"%s\"'" path)
398            (tramp-smb-maybe-open-connection user host share)            (tramp-smb-maybe-open-connection user host share)
399            (tramp-smb-send-command user host (format "dir \"%s*\"" file))))            (tramp-smb-send-command user host (format "dir \"%s\"" file))))
400    
401        (let (entry list)        (let ((curbuf (current-buffer))
402          (insert-buffer-substring              res entry diskinfo)
          (tramp-get-buffer nil tramp-smb-method user host))  
403    
404          ;; read entries          ;; Read entries
405            (set-buffer (tramp-get-buffer nil tramp-smb-method user host))
406          (beginning-of-buffer)          (beginning-of-buffer)
407          (while (setq entry (tramp-smb-read-file-entry))          (while (setq entry (tramp-smb-read-file-entry))
408            (add-to-list 'list entry)            (add-to-list 'res entry)
409            (delete-region (point) (1+ (tramp-point-at-eol))))            (forward-line))
   
         (delete-region (point) (re-search-forward "\\s-+"))  
         (forward-line 1)  
         (delete-region (point) (point-max))  
410    
411          ; print entries          ;; Read disk information
412            (forward-line)
413            (point)
414            (skip-chars-forward " \t")
415            (point)
416            (setq diskinfo (buffer-substring (point) (1+ (tramp-point-at-eol))))
417    
418            ; Print entries
419            (set-buffer curbuf)
420            (when dirp (insert diskinfo))
421          (mapcar          (mapcar
422           '(lambda (x)           '(lambda (x)
423              (insert              (insert
# Line 328  SWITCHES, WILDCARD and FULL-DIRECTORY-P Line 434  SWITCHES, WILDCARD and FULL-DIRECTORY-P
434                (nth 0 x))) ; file name                (nth 0 x))) ; file name
435              (forward-line)              (forward-line)
436              (beginning-of-line))              (beginning-of-line))
437           (sort list '(lambda (x y) (string-lessp (nth 0 x) (nth 0 y)))))))))             (sort
438                res
439                '(lambda (x y)
440                   (if (string-match dired-sort-by-date-regexp dired-actual-switches)
441                       ; sort by date
442                       (time-less-p (nth 7 y) (nth 7 x))
443                     ; sort by name
444                     (string-lessp (nth 0 x) (nth 0 y))))))))))
445    
446    (defun tramp-smb-handle-rename-file
447      (filename newname &optional ok-if-already-exists)
448      "Like `rename-file' for tramp files."
449      (setq filename (expand-file-name filename)
450            newname (expand-file-name newname))
451    
452      (let ((tmpfile (file-local-copy filename)))
453    
454        (if tmpfile
455            ;; remote filename
456            (rename-file tmpfile newname ok-if-already-exists)
457    
458          ;; remote newname
459          (when (file-directory-p newname)
460            (setq newname (expand-file-name
461                          (file-name-nondirectory filename) newname)))
462          (when (and (not ok-if-already-exists)
463                     (file-exists-p newname))
464              (error "rename-file: file %s already exists" newname))
465    
466    ;      (with-parsed-tramp-file-name newname nil
467          (let (user host path)
468            (with-parsed-tramp-file-name newname l
469              (setq user l-user host l-host path l-path))
470            (save-excursion
471              (let ((share (tramp-smb-get-share path))
472                    (file  (tramp-smb-get-path  path t)))
473                (tramp-smb-maybe-open-connection user host share)
474                (tramp-message-for-buffer
475                 nil tramp-smb-method user host
476                 5 "Copying file %s to file %s..." filename newname)
477                (tramp-smb-send-command user host (format "put %s \"%s\"" filename file))
478                (tramp-message-for-buffer
479                 nil tramp-smb-method user host
480                 5 "Copying file %s to file %s...done" filename newname))))))
481    
482      (delete-file filename))
483    
484    (defun tramp-smb-handle-substitute-in-file-name (filename)
485      "Like `substitute-in-file-name' for tramp files.
486    Preserves \"$\" in file names, before \"/\" or at end of file name."
487      (tramp-run-real-handler
488       'substitute-in-file-name
489       (list (if (string-match "\\(\\$\\)\\(/\\|$\\)" filename)
490                 (replace-match "$$" nil nil filename 1)
491               filename))))
492    
493    (defun tramp-smb-handle-write-region
494      (start end filename &optional append visit lockname confirm)
495      "Like `write-region' for tramp files."
496      (unless (eq append nil)
497        (error "Cannot append to file using tramp (`%s')" filename))
498      (setq filename (expand-file-name filename))
499      ;; XEmacs takes a coding system as the seventh argument, not `confirm'
500      (when (and (not (featurep 'xemacs))
501                 confirm (file-exists-p filename))
502        (unless (y-or-n-p (format "File %s exists; overwrite anyway? "
503                                  filename))
504          (error "File not overwritten")))
505    ;  (with-parsed-tramp-file-name filename nil
506      (let (user host path)
507        (with-parsed-tramp-file-name filename l
508          (setq user l-user host l-host path l-path))
509        (save-excursion
510          (let ((share (tramp-smb-get-share path))
511                (file  (tramp-smb-get-path  path t))
512                (curbuf (current-buffer))
513                (trampbuf (get-buffer-create "*tramp output*"))
514                ;; We use this to save the value of `last-coding-system-used'
515                ;; after writing the tmp file.  At the end of the function,
516                ;; we set `last-coding-system-used' to this saved value.
517                ;; This way, any intermediary coding systems used while
518                ;; talking to the remote shell or suchlike won't hose this
519                ;; variable.  This approach was snarfed from ange-ftp.el.
520                coding-system-used
521                tmpfil)
522            ;; Write region into a tmp file.
523            (setq tmpfil (tramp-make-temp-file))
524            ;; We say `no-message' here because we don't want the visited file
525            ;; modtime data to be clobbered from the temp file.  We call
526            ;; `set-visited-file-modtime' ourselves later on.
527            (tramp-run-real-handler
528             'write-region
529             (if confirm ; don't pass this arg unless defined for backward compat.
530                 (list start end tmpfil append 'no-message lockname confirm)
531               (list start end tmpfil append 'no-message lockname)))
532            ;; Now, `last-coding-system-used' has the right value.  Remember it.
533            (when (boundp 'last-coding-system-used)
534              (setq coding-system-used last-coding-system-used))
535    
536  (defun tramp-smb-handle-set-visited-file-modtime (&optional time-list)          (tramp-smb-maybe-open-connection user host share)
537    "Like `set-visited-file-modtime' for tramp files."          (tramp-message-for-buffer
538    nil)           nil tramp-smb-method user host
539             5 "Writing tmp file %s to file %s..." tmpfil filename)
540            (tramp-smb-send-command user host (format "put %s \"%s\"" tmpfil file))
541            (tramp-message-for-buffer
542             nil tramp-smb-method user host
543             5 "Writing tmp file %s to file %s...done" tmpfil filename)
544    
545  (defun tramp-smb-handle-verify-visited-file-modtime (buf)          (delete-file tmpfil)
546    "Like `verify-visited-file-modtime' for tramp files."          (unless (equal curbuf (current-buffer))
547    nil)            (error "Buffer has changed from `%s' to `%s'"
548                     curbuf (current-buffer)))
549            (when (eq visit t)
550              (set-visited-file-modtime))
551            ;; Make `last-coding-system-used' have the right value.
552            (when (boundp 'last-coding-system-used)
553              (setq last-coding-system-used coding-system-used))))))
554    
555    
556  ;; Internal file name functions  ;; Internal file name functions
# Line 502  connection if a previous connection has Line 716  connection if a previous connection has
716        (when (and tramp-last-cmd-time        (when (and tramp-last-cmd-time
717                   (> (tramp-time-diff (current-time) tramp-last-cmd-time) 60)                   (> (tramp-time-diff (current-time) tramp-last-cmd-time) 60)
718                   p (processp p) (memq (process-status p) '(run open)))                   p (processp p) (memq (process-status p) '(run open)))
719          (unless (tramp-smb-send-command user host "help")          (unless (tramp-smb-send-command user host "dir .")
720            (delete-process p)            (delete-process p)
721            (setq p nil))            (setq p nil))
722          (erase-buffer)))          (erase-buffer)))
# Line 554  If USER is nil, uses value returned by ` Line 768  If USER is nil, uses value returned by `
768  Sets position to begin of buffer.  Returns nil if `tramp-smb-prompt'  Sets position to begin of buffer.  Returns nil if `tramp-smb-prompt'
769  is not found."  is not found."
770    (save-excursion    (save-excursion
771      (let ((proc (get-buffer-process (current-buffer)))      (let* ((proc (get-buffer-process (current-buffer)))
772            (found nil)             (found (not proc))
773            (start-time (current-time))             (start-time (current-time))
774            (timeout 10))             (timeout 10))
775      ;; Algorithm: get waiting output.  See if last line contains      ;; Algorithm: get waiting output.  See if last line contains
776      ;; tramp-smb-prompt sentinel.  If not, wait a bit and again get      ;; tramp-smb-prompt sentinel.  If not, wait a bit and again get
777      ;; waiting output.  Repeat until timeout expires or tramp-smb-prompt      ;; waiting output.  Repeat until timeout expires or tramp-smb-prompt
# Line 574  is not found." Line 788  is not found."
788                (accept-process-output proc 1)                (accept-process-output proc 1)
789                (goto-char (point-max))                (goto-char (point-max))
790                (beginning-of-line)                (beginning-of-line)
791                (setq found (looking-at tramp-smb-prompt))))))                (setq found
792                        (or (looking-at tramp-smb-prompt)
793                            (equal 'exit (process-status proc))))))))
794        ;; Add output to debug buffer if appropriate.        ;; Add output to debug buffer if appropriate.
795        (when tramp-debug-buffer        (when tramp-debug-buffer
796          (append-to-buffer          (append-to-buffer
# Line 591  is not found." Line 807  is not found."
807        ;; Return value is whether tramp-smb-prompt sentinel was found.        ;; Return value is whether tramp-smb-prompt sentinel was found.
808        found)))        found)))
809    
810    (defun tramp-smb-check-shares (user host)
811      "Return all share names accessible on HOST, using `tramp-smb-program'."
812      (let* ((buffer (tramp-get-buffer nil tramp-smb-method user host))
813             (p (get-buffer-process buffer))
814             (default-directory (tramp-temporary-file-directory))
815             line res)
816        (save-excursion
817          (save-match-data
818            ;; Kill running processes
819            (and p (processp p) (delete-process p))
820    
821            ;; Send list command
822            (tramp-pre-connection nil tramp-smb-method user host)
823            (tramp-message 7 "List shares for //%s..." host)
824            (setq p (funcall 'start-process
825                             (buffer-name buffer)
826                             buffer
827                             tramp-smb-program
828                             "-N" "-L" host))
829            (process-kill-without-query p)
830            (tramp-smb-wait-for-output user host)
831            (setq tramp-smb-share "")
832    
833            ;; Read shares
834            (goto-char (point-min))
835            (while (not (eobp))
836              (setq line (buffer-substring (point) (tramp-point-at-eol)))
837              (when (string-match "^\\s-+\\(\\S-+\\)\\s-+Disk" line)
838                (add-to-list 'res (list (concat (match-string 1 line) "/"))))
839              (forward-line))))
840        res))
841    
842  (provide 'tramp-smb)  (provide 'tramp-smb)
843    
844  ;;; TODO:  ;;; TODO:
# Line 601  is not found." Line 849  is not found."
849  ;; * Update documentation.  ;; * Update documentation.
850  ;; * In `tramp-smb-handle-insert-directory', compute 183 days differences  ;; * In `tramp-smb-handle-insert-directory', compute 183 days differences
851  ;;   for decision whether to print time or year string.  ;;   for decision whether to print time or year string.
852    ;  * Return more comprehensive file permission string.
853  ;; * Replace `date-to-time' by `encode-time', because existence of  ;; * Replace `date-to-time' by `encode-time', because existence of
854  ;;   `time-date.el' cannot be assumed.  ;;   `time-date.el' cannot be assumed. `time-less-p' is a problem as well.
855    ;; * Support port numbers for servers ("host#port" syntax), applying
856    ;;   parameter "-p".
857  ;; * Provide variables for debug.  ;; * Provide variables for debug.
858    ;; * (RMS) Use unwind-protect to clean up the state so as to make the state
859    ;;    regular again.
860    
861  ;;; tramp-smb.el ends here  ;;; tramp-smb.el ends here

Legend:
Removed from v.2.5  
changed lines
  Added in v.2.6

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