Mercurial > emacs
comparison lisp/net/tramp-smb.el @ 105634:75fb0870b7e0
* net/tramp-smb.el (tramp-smb-version): New defvar.
(tramp-smb-maybe-open-connection): Use it, in order to avoid
repeated checks.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Fri, 16 Oct 2009 14:36:02 +0000 |
parents | 13878abadf01 |
children | 8d8fc5285759 |
comparison
equal
deleted
inserted
replaced
105633:411fa34ae614 | 105634:75fb0870b7e0 |
---|---|
58 | 58 |
59 (defcustom tramp-smb-program "smbclient" | 59 (defcustom tramp-smb-program "smbclient" |
60 "*Name of SMB client to run." | 60 "*Name of SMB client to run." |
61 :group 'tramp | 61 :group 'tramp |
62 :type 'string) | 62 :type 'string) |
63 | |
64 (defvar tramp-smb-version nil | |
65 "*Version string of the SMB client.") | |
63 | 66 |
64 (defconst tramp-smb-prompt "^smb: .+> \\|^\\s-+Server\\s-+Comment$" | 67 (defconst tramp-smb-prompt "^smb: .+> \\|^\\s-+Server\\s-+Comment$" |
65 "Regexp used as prompt in smbclient.") | 68 "Regexp used as prompt in smbclient.") |
66 | 69 |
67 (defconst tramp-smb-errors | 70 (defconst tramp-smb-errors |
1207 (tramp-error | 1210 (tramp-error |
1208 vec 'file-error | 1211 vec 'file-error |
1209 "Cannot find command %s in %s" tramp-smb-program exec-path)) | 1212 "Cannot find command %s in %s" tramp-smb-program exec-path)) |
1210 | 1213 |
1211 (let* ((default-directory (tramp-compat-temporary-file-directory)) | 1214 (let* ((default-directory (tramp-compat-temporary-file-directory)) |
1212 (smbclient-version | 1215 (smbclient-version tramp-smb-version)) |
1213 (shell-command-to-string (concat tramp-smb-program " -V")))) | 1216 (unless smbclient-version |
1214 (tramp-message vec 6 (concat tramp-smb-program " -V")) | 1217 (setq smbclient-version |
1215 (tramp-message vec 6 "\n%s" smbclient-version) | 1218 (shell-command-to-string (concat tramp-smb-program " -V"))) |
1216 (if (string-match "[ \t\n\r]+\\'" smbclient-version) | 1219 (tramp-message vec 6 (concat tramp-smb-program " -V")) |
1217 (setq smbclient-version | 1220 (tramp-message vec 6 "\n%s" smbclient-version) |
1218 (replace-match "" nil nil smbclient-version))) | 1221 (if (string-match "[ \t\n\r]+\\'" smbclient-version) |
1222 (setq smbclient-version | |
1223 (replace-match "" nil nil smbclient-version)))) | |
1219 (unless | 1224 (unless |
1220 (string-equal | 1225 (string-equal |
1221 smbclient-version | 1226 smbclient-version |
1222 (tramp-get-connection-property | 1227 (tramp-get-connection-property |
1223 vec "smbclient-version" smbclient-version)) | 1228 vec "smbclient-version" smbclient-version)) |
1224 (tramp-flush-directory-property vec "") | 1229 (tramp-flush-directory-property vec "") |
1225 (tramp-flush-connection-property vec)) | 1230 (tramp-flush-connection-property vec)) |
1226 (tramp-set-connection-property | 1231 (setq tramp-smb-version |
1227 vec "smbclient-version" smbclient-version))) | 1232 (tramp-set-connection-property |
1233 vec "smbclient-version" smbclient-version)))) | |
1228 | 1234 |
1229 ;; If too much time has passed since last command was sent, look | 1235 ;; If too much time has passed since last command was sent, look |
1230 ;; whether there has been an error message; maybe due to | 1236 ;; whether there has been an error message; maybe due to |
1231 ;; connection timeout. | 1237 ;; connection timeout. |
1232 (with-current-buffer buf | 1238 (with-current-buffer buf |