emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: testing for a remote file to include file on a Windows mapped drive


From: Drew Adams
Subject: RE: testing for a remote file to include file on a Windows mapped drive
Date: Sun, 20 Apr 2008 11:28:47 -0700

I'm returning to this thread because I don't know what was finally done wrt what
I asked for in starting the thread: Treat a file name with a Windows mapped
network drive as remote but one with a local drive as not remote.

Could someone please summarize what was done about this? The thread seems to
have drifted away from its target, and I can't tell what the outcome was.

I'm still using the code I mentioned (see below), which tries NET USE on
Windows. Is that part perhaps unneeded now, because an equivalent is done by
Emacs itself? Note that while I find the NET USE code to be quick, a couple of
users have reported that it can seem to hang. Suggestions about that?

Also, could someone please reply specifically to my last message in the thread,
below (e.g. `file-remote-p' vs `ffap-remote-p')?

Thx.

> From: Drew Adams Sent: Saturday, January 26, 2008 5:36 PM
>
> I'm not looking for something that needs to be "independent 
> of the syntax". It could use the syntax sometimes, but it
> might need to go beyond the syntax sometimes. On Windows,
> it would need to be able to tell when "h:/foo" might
> name a file on a network drive, and the syntax alone won't 
> suffice for that. I think Stefan suggested something similar
> for symbolic links on other platforms.
> 
> I'm looking for something that will, as you say, "never open 
> a connection on its own". I'm interested in saving time. I
> want to distinguish a string that is likely to name a remote
> file or a file on a mapped network drive from a string that
> is likely to name a local file. That's all.
> 
> The problem I posed was that I couldn't find a function that 
> makes that distinction. `file-remote-p', in particular,
> returns nil for a file that is on a mapped network drive.
> 
> I don't care what the function is called - whether (a) 
> `file-remote-p' is tweaked to return non-nil for a file on a
> network drive or (b) some other function is provided; either
> would be fine by me.
> 
> FWIW, I am currently using Eli's "NET USE" suggestion
> (thanks). It distinguishes network drives from local drives
> and non-existent drives, which is sufficient for my use.
> (AFAICT, it does not distinguish a local drive from a
> non-existent drive, but that's OK.) This is what I have now:
> 
> (defun my-file-remote-p (file)
>   "Non-nil means FILE is likely to name a file on a remote system.
> For MS Windows, this includes a file on a mapped network drive."
>   (or (and (eq system-type 'windows-nt)
>            (let ((case-fold-search t))
>              (and (string-match "\\`\\([a-z]:\\)" file)
>                   (eq 0 (condition-case nil
>                             (call-process
>                              shell-file-name nil nil nil
>                              shell-command-switch
>                              (concat "NET USE "
>                                      (match-string 1 file)))
>                           (error nil))))))
>       (and (fboundp 'ffap-file-remote-p)
>            (ffap-file-remote-p file))
>       (file-remote-p file)))
> 
> I'm not necessarily suggesting this for Emacs; I'm just 
> saying that it seems to work for me.
> 
> BTW: Can `file-remote-p' ever return non-nil when 
> `ffap-remote-p' returns nil? If not, I'll remove the
> `ffap-remote-p' test. My guess is that neither
> is a proper subset of the other, so I use both.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]