From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Toru TSUNEYOSHI Newsgroups: gmane.emacs.devel Subject: ange-ftp-file-size Date: Thu, 15 Oct 2009 12:20:16 +0900 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Oct_15_12_20_16_2009_333)--" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1255576859 13541 80.91.229.12 (15 Oct 2009 03:20:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Oct 2009 03:20:59 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 15 05:20:48 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MyGtT-0008SI-TM for ged-emacs-devel@m.gmane.org; Thu, 15 Oct 2009 05:20:48 +0200 Original-Received: from localhost ([127.0.0.1]:38813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyGtT-0000kj-8g for ged-emacs-devel@m.gmane.org; Wed, 14 Oct 2009 23:20:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MyGtO-0000k2-1W for emacs-devel@gnu.org; Wed, 14 Oct 2009 23:20:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MyGtJ-0000jD-Ir for emacs-devel@gnu.org; Wed, 14 Oct 2009 23:20:41 -0400 Original-Received: from [199.232.76.173] (port=43337 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyGtJ-0000jA-Dn for emacs-devel@gnu.org; Wed, 14 Oct 2009 23:20:37 -0400 Original-Received: from blu0-omc4-s9.blu0.hotmail.com ([65.55.111.148]:10575) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MyGtJ-0001CO-7b for emacs-devel@gnu.org; Wed, 14 Oct 2009 23:20:37 -0400 Original-Received: from BLU0-SMTP67 ([65.55.111.135]) by blu0-omc4-s9.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 14 Oct 2009 20:20:36 -0700 X-Originating-IP: [124.155.30.210] X-Originating-Email: [t_tuneyosi@hotmail.com] Original-Received: from localhost ([124.155.30.210]) by BLU0-SMTP67.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 14 Oct 2009 20:20:35 -0700 X-Mailer: Mew version 6.2 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) X-OriginalArrivalTime: 15 Oct 2009 03:20:36.0127 (UTC) FILETIME=[764CBAF0:01CA4D46] X-detected-operating-system: by monty-python.gnu.org: Windows 2000 SP4, XP SP1+ X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:116155 Archived-At: ----Next_Part(Thu_Oct_15_12_20_16_2009_333)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello. Now, ange-ftp-file-attributes doesn't return the file size. It returns -1. I wish it returns the size exactly, so I make ange-ftp-file-size. If no problem, would you like to apply to ange-ftp.el, and modify code at the size of ange-ftp-file-attributes ? ----Next_Part(Thu_Oct_15_12_20_16_2009_333)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ange-ftp-file-size.el" ;; After the style of `ange-ftp-file-modtime'. ;; *** I don't check return code 226 on wu-ftpd. *** (defun ange-ftp-file-size (file &optional ascii-mode) "Return the size of remote file FILE. Return -1 if can't get it. If ascii-mode is non-nil, return the size with the extra octets that need to be inserted, one at the end of each line, to provide correct end-of-line semantics for a transfer using TYPE=A. The default is nil, so return the size on the remote host exactly. See RFC 3659." (let* ((parsed (ange-ftp-ftp-name file)) (host (nth 0 parsed)) (user (nth 1 parsed)) (name (ange-ftp-quote-string (nth 2 parsed))) ;; At least one FTP server (wu-ftpd) can return a "226 ;; Transfer complete" before the "213 SIZE". Let's skip ;; that. (ange-ftp-skip-msgs (concat ange-ftp-skip-msgs "\\|^226")) (res (prog2 (unless ascii-mode (ange-ftp-set-binary-mode host user)) (ange-ftp-send-cmd host user (list 'quote "size" name)) (unless ascii-mode (ange-ftp-set-ascii-mode host user)))) (line (cdr res)) (size -1)) (save-match-data (when (string-match "^213 \\([0-9]+\\)$" line) (setq size (string-to-number (match-string 1 line))))) size)) ----Next_Part(Thu_Oct_15_12_20_16_2009_333)----