Function: ange-ftp-file-modtime

ange-ftp-file-modtime is a byte-compiled function defined in ange-ftp.el.gz.

Signature

(ange-ftp-file-modtime FILE)

Documentation

Return the modification time of remote file FILE.

Value is (0 0) if the modification time cannot be determined.

Source Code

;; Defined in /usr/src/emacs/lisp/net/ange-ftp.el.gz
(defun ange-ftp-file-modtime (file)
  "Return the modification time of remote file FILE.
Value is (0 0) if the modification time cannot be determined."
  (let* ((parsed (ange-ftp-ftp-name file))
	 ;; At least one FTP server (wu-ftpd) can return a "226
	 ;; Transfer complete" before the "213 MODTIME".  Let's skip
	 ;; that.
	 (ange-ftp-skip-msgs (concat ange-ftp-skip-msgs "\\|^226"))
         (res (ange-ftp-send-cmd (car parsed) (cadr parsed)
                                 (list 'quote "mdtm" (cadr (cdr parsed)))))
	 (line (cdr res))
	 (modtime '(0 0)))
    ;; MDTM should return "213 YYYYMMDDhhmmss" GMT on success
    ;; following the Internet draft for FTP extensions.
    ;; Bob@rattlesnake.com reports that is returns something different
    ;; for at least one FTP server.  So, let's use the response only
    ;; if it matches the Internet draft.
    (when (string-match-p "^213 [0-9]\\{14\\}$" line)
      (setq modtime
	    (encode-time
	     (string-to-number (substring line 16 18))
	     (string-to-number (substring line 14 16))
	     (string-to-number (substring line 12 14))
	     (string-to-number (substring line 10 12))
	     (string-to-number (substring line  8 10))
	     (string-to-number (substring line  4  8))
	     0)))
    modtime))