| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
(eval-when-compile (require 'cl)) |
|---|
| 30 |
(require 'url-parse) |
|---|
| 31 |
(require 'url-file) |
|---|
| 32 |
|
|---|
| 33 |
(defvar url-nfs-automounter-directory-spec |
|---|
| 34 |
"file:/net/%h%f" |
|---|
| 35 |
"*How to invoke the NFS automounter. Certain % sequences are recognized. |
|---|
| 36 |
|
|---|
| 37 |
%h -- the hostname of the NFS server |
|---|
| 38 |
%n -- the port # of the NFS server |
|---|
| 39 |
%u -- the username to use to authenticate |
|---|
| 40 |
%p -- the password to use to authenticate |
|---|
| 41 |
%f -- the filename on the remote server |
|---|
| 42 |
%% -- a literal % |
|---|
| 43 |
|
|---|
| 44 |
Each can be used any number of times.") |
|---|
| 45 |
|
|---|
| 46 |
(defun url-nfs-unescape (format host port user pass file) |
|---|
| 47 |
(save-excursion |
|---|
| 48 |
(set-buffer (get-buffer-create " *nfs-parse*")) |
|---|
| 49 |
(erase-buffer) |
|---|
| 50 |
(insert format) |
|---|
| 51 |
(goto-char (point-min)) |
|---|
| 52 |
(while (re-search-forward "%\\(.\\)" nil t) |
|---|
| 53 |
(let ((escape (aref (match-string 1) 0))) |
|---|
| 54 |
(replace-match "" t t) |
|---|
| 55 |
(case escape |
|---|
| 56 |
(?% (insert "%")) |
|---|
| 57 |
(?h (insert host)) |
|---|
| 58 |
(?n (insert (or port ""))) |
|---|
| 59 |
(?u (insert (or user ""))) |
|---|
| 60 |
(?p (insert (or pass ""))) |
|---|
| 61 |
(?f (insert (or file "/")))))) |
|---|
| 62 |
(buffer-string))) |
|---|
| 63 |
|
|---|
| 64 |
(defun url-nfs-build-filename (url) |
|---|
| 65 |
(let* ((host (url-host url)) |
|---|
| 66 |
(port (url-port url)) |
|---|
| 67 |
(pass (url-password url)) |
|---|
| 68 |
(user (url-user url)) |
|---|
| 69 |
(file (url-filename url))) |
|---|
| 70 |
(url-generic-parse-url |
|---|
| 71 |
(url-nfs-unescape url-nfs-automounter-directory-spec |
|---|
| 72 |
host port user pass file)))) |
|---|
| 73 |
|
|---|
| 74 |
(defun url-nfs (url callback cbargs) |
|---|
| 75 |
(url-file (url-nfs-build-filename url) callback cbargs)) |
|---|
| 76 |
|
|---|
| 77 |
(defmacro url-nfs-create-wrapper (method args) |
|---|
| 78 |
`(defun ,(intern (format "url-nfs-%s" method)) ,args |
|---|
| 79 |
,(format "NFS URL wrapper around `%s' call." method) |
|---|
| 80 |
(setq url (url-nfs-build-filename url)) |
|---|
| 81 |
(and url (,(intern (format "url-file-%s" method)) |
|---|
| 82 |
,@(remove '&rest (remove '&optional args)))))) |
|---|
| 83 |
|
|---|
| 84 |
(url-nfs-create-wrapper file-exists-p (url)) |
|---|
| 85 |
(url-nfs-create-wrapper file-attributes (url &optional id-format)) |
|---|
| 86 |
(url-nfs-create-wrapper file-symlink-p (url)) |
|---|
| 87 |
(url-nfs-create-wrapper file-readable-p (url)) |
|---|
| 88 |
(url-nfs-create-wrapper file-writable-p (url)) |
|---|
| 89 |
(url-nfs-create-wrapper file-executable-p (url)) |
|---|
| 90 |
(url-nfs-create-wrapper directory-files (url &optional full match nosort)) |
|---|
| 91 |
(url-nfs-create-wrapper file-truename (url &optional counter prev-dirs)) |
|---|
| 92 |
|
|---|
| 93 |
(provide 'url-nfs) |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|