Mercurial > emacs
comparison lisp/url/url-handlers.el @ 91586:cac14d4ce88f
* url-handlers.el (file-remote-p): Add handler.
(url-handler-file-remote-p): New fun.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Wed, 06 Feb 2008 20:34:03 +0000 |
parents | 9c08b66c6c21 |
children | 8259d0d8e107 |
comparison
equal
deleted
inserted
replaced
91585:4fe734146ac9 | 91586:cac14d4ce88f |
---|---|
71 ;; file-name-sans-versions why? | 71 ;; file-name-sans-versions why? |
72 ;; file-newer-than-file-p | 72 ;; file-newer-than-file-p |
73 ;; file-ownership-preserved-p No way to know | 73 ;; file-ownership-preserved-p No way to know |
74 ;; file-readable-p Finished | 74 ;; file-readable-p Finished |
75 ;; file-regular-p !directory_p | 75 ;; file-regular-p !directory_p |
76 ;; file-remote-p Finished | |
76 ;; file-symlink-p Needs DAV bindings | 77 ;; file-symlink-p Needs DAV bindings |
77 ;; file-truename Needs DAV bindings | 78 ;; file-truename Needs DAV bindings |
78 ;; file-writable-p Check for LOCK? | 79 ;; file-writable-p Check for LOCK? |
79 ;; find-backup-file-name why? | 80 ;; find-backup-file-name why? |
80 ;; get-file-buffer why? | 81 ;; get-file-buffer why? |
149 (put 'substitute-in-file-name 'url-file-handlers 'url-file-handler-identity) | 150 (put 'substitute-in-file-name 'url-file-handlers 'url-file-handler-identity) |
150 (put 'file-name-absolute-p 'url-file-handlers (lambda (&rest ignored) t)) | 151 (put 'file-name-absolute-p 'url-file-handlers (lambda (&rest ignored) t)) |
151 (put 'expand-file-name 'url-file-handlers 'url-handler-expand-file-name) | 152 (put 'expand-file-name 'url-file-handlers 'url-handler-expand-file-name) |
152 (put 'directory-file-name 'url-file-handlers 'url-handler-directory-file-name) | 153 (put 'directory-file-name 'url-file-handlers 'url-handler-directory-file-name) |
153 (put 'unhandled-file-name-directory 'url-file-handlers 'url-handler-unhandled-file-name-directory) | 154 (put 'unhandled-file-name-directory 'url-file-handlers 'url-handler-unhandled-file-name-directory) |
155 (put 'file-remote-p 'url-file-handlers 'url-handler-file-remote-p) | |
154 ;; (put 'file-name-as-directory 'url-file-handlers 'url-handler-file-name-as-directory) | 156 ;; (put 'file-name-as-directory 'url-file-handlers 'url-handler-file-name-as-directory) |
155 | 157 |
156 ;; These are operations that we do not support yet (DAV!!!) | 158 ;; These are operations that we do not support yet (DAV!!!) |
157 (put 'file-writable-p 'url-file-handlers 'ignore) | 159 (put 'file-writable-p 'url-file-handlers 'ignore) |
158 (put 'file-symlink-p 'url-file-handlers 'ignore) | 160 (put 'file-symlink-p 'url-file-handlers 'ignore) |
190 ;; FIXME: maybe we should check that the host part is "" or "localhost" | 192 ;; FIXME: maybe we should check that the host part is "" or "localhost" |
191 ;; or some name that represents the local host? | 193 ;; or some name that represents the local host? |
192 (or (file-name-directory (url-filename url)) "/") | 194 (or (file-name-directory (url-filename url)) "/") |
193 ;; All other URLs are not expected to be directly accessible from | 195 ;; All other URLs are not expected to be directly accessible from |
194 ;; a local process. | 196 ;; a local process. |
197 nil))) | |
198 | |
199 (defun url-handler-file-remote-p (filename &optional identification connected) | |
200 (let ((url (url-generic-parse-url filename))) | |
201 (if (and (url-type url) (not (equal (url-type url) "file"))) | |
202 ;; Maybe we can find a suitable check for CONNECTED. For now, | |
203 ;; we ignore it. | |
204 (cond | |
205 ((eq identification 'method) (url-type url)) | |
206 ((eq identification 'user) (url-user url)) | |
207 ((eq identification 'host) (url-host url)) | |
208 ((eq identification 'localname) (url-filename url)) | |
209 (t (url-recreate-url | |
210 (url-parse-make-urlobj (url-type url) (url-user url) nil | |
211 (url-host url) (url-port url))))) | |
212 ;; If there is no URL type, or it is a "file://" URL, the | |
213 ;; filename is expected to be non remote. A more subtle check | |
214 ;; for "file://" URLs could be applied, as said in | |
215 ;; `url-handler-unhandled-file-name-directory'. | |
195 nil))) | 216 nil))) |
196 | 217 |
197 ;; The actual implementation | 218 ;; The actual implementation |
198 ;;;###autoload | 219 ;;;###autoload |
199 (defun url-copy-file (url newname &optional ok-if-already-exists keep-time) | 220 (defun url-copy-file (url newname &optional ok-if-already-exists keep-time) |