;;; tramp-adb.el --- Functions for calling Android Debug Bridge from Tramp
-;; Copyright (C) 2011-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
;; Author: Jürgen Hötzel <juergen@archlinux.org>
;; Keywords: comm, processes
;;; Code:
(require 'tramp)
-(require 'time-date)
;; Pacify byte-compiler.
(defvar directory-sep-char)
(defun tramp-adb-handle-file-attributes (filename &optional id-format)
"Like `file-attributes' for Tramp files."
(unless id-format (setq id-format 'integer))
- (with-parsed-tramp-file-name filename nil
- (with-tramp-file-property
- v localname (format "file-attributes-%s" id-format)
- (and
- (tramp-adb-send-command-and-check
- v (format "%s -d -l %s"
- (tramp-adb-get-ls-command v)
- (tramp-shell-quote-argument localname)))
- (with-current-buffer (tramp-get-buffer v)
- (tramp-adb-sh-fix-ls-output)
- (cdar (tramp-do-parse-file-attributes-with-ls v id-format)))))))
+ (ignore-errors
+ (with-parsed-tramp-file-name filename nil
+ (with-tramp-file-property
+ v localname (format "file-attributes-%s" id-format)
+ (and
+ (tramp-adb-send-command-and-check
+ v (format "%s -d -l %s"
+ (tramp-adb-get-ls-command v)
+ (tramp-shell-quote-argument localname)))
+ (with-current-buffer (tramp-get-buffer v)
+ (tramp-adb-sh-fix-ls-output)
+ (cdar (tramp-do-parse-file-attributes-with-ls v id-format))))))))
(defun tramp-do-parse-file-attributes-with-ls (vec &optional id-format)
"Parse `file-attributes' for Tramp files using the ls(1) command."
(setq time-a (apply 'encode-time (parse-time-string (match-string 0 a))))
(string-match tramp-adb-ls-date-regexp b)
(setq time-b (apply 'encode-time (parse-time-string (match-string 0 b))))
- (tramp-time-less-p time-b time-a)))
+ (time-less-p time-b time-a)))
(defun tramp-adb-ls-output-name-less-p (a b)
"Sort \"ls\" output by name, ascending."
;; directory.
(condition-case nil
(progn
- (setq ret 0)
- (tramp-adb-barf-unless-okay
- v (format "(cd %s; %s)"
- (tramp-shell-quote-argument localname) command)
- "")
+ (setq ret
+ (if (tramp-adb-send-command-and-check
+ v
+ (format "(cd %s; %s)"
+ (tramp-shell-quote-argument localname) command))
+ ;; Set return status accordingly.
+ 0 1))
;; We should add the output anyway.
(when outbuf
(with-current-buffer outbuf
(defun tramp-adb-send-command-and-check
(vec command)
"Run COMMAND and check its exit status.
-Sends `echo $?' along with the COMMAND for checking the exit status. If
-COMMAND is nil, just sends `echo $?'. Returns the exit status found."
+Sends `echo $?' along with the COMMAND for checking the exit
+status. If COMMAND is nil, just sends `echo $?'. Returns nil if
+the exit status is not equal 0, and t otherwise."
(tramp-adb-send-command
vec (if command
(format "%s; echo tramp_exit_status $?" command)