[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tiny patch to ange-ftp
From: |
Katsumi Yamaoka |
Subject: |
Re: tiny patch to ange-ftp |
Date: |
Wed, 10 Aug 2005 20:25:18 +0900 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
>>>>> In <address@hidden> Katsumi Yamaoka wrote:
> I confirmed it in the ftp.netbsd.org host, oops. I agree to
> revert it, er,...
I reverted it so that ange-ftp can be used with NetBSD's ftpd as
well. Following up to it, I modified `ange-ftp-ls' so as to
make it return a single line when listing a file, not a directory.
It is necessary when uploading files:
> AFAIK, the result of the `ls "-switches remote-file" local-file'
> form is required only when updating the dired buffer just after
> uploading a file.
In addition, after reverting it, while I got another error when
accessing symlinks, I already fixed it.
Here's a new patch:
2005-08-10 Katsumi Yamaoka <address@hidden> (tiny change)
* net/ange-ftp.el (ange-ftp-send-cmd): Withdraw the last change,
which made it impossible to connect to NetBSD's ftpd; make it work
even when accessing symlinks.
(ange-ftp-ls): Return a single line when listing a file.
(ange-ftp-canonize-filename): Add comments.
--8<---------------cut here---------------start------------->8---
*** ange-ftp.el~ Tue Aug 9 21:56:54 2005
--- ange-ftp.el Wed Aug 10 11:14:04 2005
***************
*** 2328,2340 ****
;; We cd and then use `ls' with no directory argument.
;; This works around a misfeature of some versions of netbsd ftpd.
(unless (equal cmd1 ".")
! (setq result (ange-ftp-cd host user
! ;; Make sure the target to which
! ;; `cd' is performed is a directory.
! (file-name-directory (nth 1 cmd))
! 'noerror)))
! ;; Concatenate the switches and the target to be used with `ls'.
! (setq cmd1 (concat "\"" cmd3 " " cmd1 "\""))))
;; First argument is the remote name
((progn
--- 2328,2342 ----
;; We cd and then use `ls' with no directory argument.
;; This works around a misfeature of some versions of netbsd ftpd.
(unless (equal cmd1 ".")
! (setq result (condition-case nil
! (ange-ftp-cd host user (nth 1 cmd))
! (error
! ;; The target `(nth 1 cmd)' might be a file, so
! ;; we attempt to cd to the parent directory.
! (ange-ftp-cd host user
! (file-name-directory (nth 1 cmd))
! 'noerror)))))
! (setq cmd1 cmd3)))
;; First argument is the remote name
((progn
***************
*** 2638,2643 ****
--- 2640,2663 ----
;; that is being queried is other than Unix i.e. VMS
;; returns an ls format that really sucks.
(run-hooks 'ange-ftp-after-parse-ls-hook)
+ ;; If `file' is a file, we remove other lines.
+ (unless parse
+ (goto-char (point-min))
+ (let ((re (concat "[\t ]+" (regexp-quote file) "$"))
+ lines)
+ (while (re-search-forward re nil t)
+ (push (cons (- (match-end 0) (match-beginning 0))
+ (buffer-substring
+ (line-beginning-position)
+ (match-end 0)))
+ lines))
+ (erase-buffer)
+ (insert
+ ;; There may be files of which names begin with SPC.
+ (if (> (length lines) 1)
+ (cdar (sort lines 'car-less-than-car))
+ (or (cdar (last lines)) ""))
+ "\n")))
(setq ange-ftp-ls-cache-file key
ange-ftp-ls-cache-lsargs lsargs
; For dumb hosts-types this is
***************
*** 3127,3138 ****
(rest (substring name (match-end 0)))
(dir (ange-ftp-expand-dir host user tilda)))
(if dir
! (setq name (cond ((string-equal rest "")
! dir)
! ((string-equal dir "/")
! rest)
! (t
! (concat dir rest))))
(error "User \"%s\" is not known"
(substring tilda 1)))))
--- 3147,3168 ----
(rest (substring name (match-end 0)))
(dir (ange-ftp-expand-dir host user tilda)))
(if dir
! (setq name
! (cond ((string-equal rest "")
! ;; The case accessing ~ or ~user.
! ;; `dir' may be chroot'ed.
! dir)
! ((string-equal dir "/")
! ;; The case accessing ~/file or ~user/file
! ;; in the chroot'ed environment.
! ;; `rest' has the value "/file".
! rest)
! (t
! ;; The case accessing ~/file or ~user/file
! ;; but chroot is not applied there. `dir'
! ;; has the expanded home directory, and
! ;; `rest' has the value "/file".
! (concat dir rest))))
(error "User \"%s\" is not known"
(substring tilda 1)))))
--8<---------------cut here---------------end--------------->8---