1417 |
;; The device number is returned as "-1", because there will be a virtual |
;; The device number is returned as "-1", because there will be a virtual |
1418 |
;; device number set in `tramp-handle-file-attributes' |
;; device number set in `tramp-handle-file-attributes' |
1419 |
(defconst tramp-perl-file-attributes "\ |
(defconst tramp-perl-file-attributes "\ |
1420 |
$f = $ARGV[0]; |
($f, $n) = @ARGV; |
1421 |
@s = lstat($f); |
@s = lstat($f); |
1422 |
if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } |
if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } |
1423 |
elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } |
elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } |
1424 |
else { $l = \"nil\" }; |
else { $l = \"nil\" }; |
1425 |
printf(\"(%s %u %d %d (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) -1)\\n\", |
$u = ($n eq \"nil\") ? $s[4] : getpwuid($s[4]); |
1426 |
$l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff, |
$g = ($n eq \"nil\") ? $s[5] : getgrgid($s[5]); |
1427 |
|
printf(\"(%s %u %s %s (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) -1)\\n\", |
1428 |
|
$l, $s[3], $u, $g, $s[8] >> 16 & 0xffff, $s[8] & 0xffff, |
1429 |
$s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, |
$s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, |
1430 |
$s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff);" |
$s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff);" |
1431 |
"Perl script to produce output suitable for use with `file-attributes' |
"Perl script to produce output suitable for use with `file-attributes' |
1914 |
(append '("") (reverse result) (list thisstep)) |
(append '("") (reverse result) (list thisstep)) |
1915 |
"/")) |
"/")) |
1916 |
(setq symlink-target |
(setq symlink-target |
1917 |
(nth 0 (tramp-handle-file-attributes |
(nth 0 (file-attributes |
1918 |
(tramp-make-tramp-file-name |
(tramp-make-tramp-file-name |
1919 |
multi-method method user host |
multi-method method user host |
1920 |
(mapconcat 'identity |
(mapconcat 'identity |
1993 |
;; CCC: This should check for an error condition and signal failure |
;; CCC: This should check for an error condition and signal failure |
1994 |
;; when something goes wrong. |
;; when something goes wrong. |
1995 |
;; Daniel Pittman <daniel@danann.net> |
;; Daniel Pittman <daniel@danann.net> |
1996 |
(defun tramp-handle-file-attributes (filename &optional nonnumeric) |
(defun tramp-handle-file-attributes (filename &optional id-format) |
1997 |
"Like `file-attributes' for tramp files. |
"Like `file-attributes' for tramp files." |
1998 |
Optional argument NONNUMERIC means return user and group name |
(let ((nonnumeric (and id-format (equal id-format 'string))) |
1999 |
rather than as numbers." |
result) |
|
(let (result) |
|
2000 |
(with-parsed-tramp-file-name filename nil |
(with-parsed-tramp-file-name filename nil |
2001 |
(when (tramp-handle-file-exists-p filename) |
(when (tramp-handle-file-exists-p filename) |
2002 |
;; file exists, find out stuff |
;; file exists, find out stuff |
2110 |
multi-method method user host localname)) |
multi-method method user host localname)) |
2111 |
(tramp-send-command |
(tramp-send-command |
2112 |
multi-method method user host |
multi-method method user host |
2113 |
(format "tramp_file_attributes %s" |
(format "tramp_file_attributes %s %s" |
2114 |
(tramp-shell-quote-argument localname))) |
(tramp-shell-quote-argument localname) nonnumeric)) |
2115 |
(tramp-wait-for-output) |
(tramp-wait-for-output) |
2116 |
(let ((result (read (current-buffer)))) |
(let ((result (read (current-buffer)))) |
2117 |
(setcar (nthcdr 8 result) |
(setcar (nthcdr 8 result) |
2323 |
(defun tramp-handle-file-symlink-p (filename) |
(defun tramp-handle-file-symlink-p (filename) |
2324 |
"Like `file-symlink-p' for tramp files." |
"Like `file-symlink-p' for tramp files." |
2325 |
(with-parsed-tramp-file-name filename nil |
(with-parsed-tramp-file-name filename nil |
2326 |
(let ((x (car (tramp-handle-file-attributes filename)))) |
(let ((x (car (file-attributes filename)))) |
2327 |
(when (stringp x) |
(when (stringp x) |
2328 |
;; When Tramp is running on VMS, then `file-name-absolute-p' |
;; When Tramp is running on VMS, then `file-name-absolute-p' |
2329 |
;; might do weird things. |
;; might do weird things. |
5305 |
multi-method method user host |
multi-method method user host |
5306 |
(concat "tramp_file_attributes () {\n" |
(concat "tramp_file_attributes () {\n" |
5307 |
tramp-remote-perl |
tramp-remote-perl |
5308 |
" -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" |
" -e '" tramp-perl-file-attributes "' $1 $2 2>/dev/null\n" |
5309 |
"}")) |
"}")) |
5310 |
(tramp-wait-for-output) |
(tramp-wait-for-output) |
5311 |
(unless (tramp-get-method-parameter |
(unless (tramp-get-method-parameter |