Subject: Re: bug#34675: 27.0.50; (MS-Windows) DND fails for UNC filename on same server

From: Richard Copley <[email-masked]>
Date: Sat, 2 Mar 2019 12:44:02 +0000

On Sat, 2 Mar 2019 at 12:01, Eli Zaretskii <[email-masked]> wrote:

> > From: Richard Copley <[email-masked]>
> > Date: Wed, 27 Feb 2019 13:41:34 +0000
> >
> > Open Windows Explorer in a file share on the local machine.
> > Drag a file from there and drop it onto Emacs.
> > The error "Can not read file:///server/share/file-name" is signalled.
> >
> > dnd-get-local-file-uri attempts to convert the remote file name to a
> local
> > file name by removing the server name. That is not valid for UNC file
> > names.
>
> Thanks, but please provide a full recipe, including the pertinent
> names of the server and the share.  Your local system isn't called
> "server", is it?  If it is, please help me by telling how you created
> such a share locally, because I don't think I know how to do that.
>
> Apologies if I'm missing something simple here.
>

Thanks for replying. I'm sorry I wasn't clear.

1. In a command prompt window, create a folder "x", and share it as
"y", and create a file "z" in the folder "x":

mkdir %HOMEDRIVE%%HOMEPATH%\x
net share y=%HOMEDRIVE%%HOMEPATH%\x
>%HOMEDRIVE%%HOMEPATH%\x\z echo.

2. Run "emacs -Q". Evaluate (system-name) in Emacs and make a note of
the result.

3. Open Explorer and enter "\\foo\y" in the address bar, where "foo"
is the system name.

4. Drag the file "z" from Explorer and drop it on Emacs. Emacs signals
an error, "dnd-open-local-file: Can not read file:///y/z".

5. Clean up:

net share y /delete
rmdir /s /q %HOMEDRIVE%%HOMEPATH%\x

End of recipe.

Just now I noticed this in the docstring of the variable
`dnd-open-remote-file-function':

"‘dnd-open-local-file’ attempts to open a remote file using its UNC name and
is the  default on MS-Windows.  ‘dnd-open-remote-url’ uses
‘url-handler-mode’
and is the default except for MS-Windows."

It sounds as though my scenario has been considered. But it is not
true now that "‘dnd-open-local-file’ attempts to open a remote file
using its UNC name".

The backtrace:

Debugger entered--Lisp error: (error "Can not read file:///y/z")
  signal(error ("Can not read file:///y/z"))
  error("Can not read %s" "file:///y/z")
  dnd-open-local-file("file:///y/z" private)
  dnd-open-file("file://foo/y/z" private)
  dnd-handle-one-url(#<window 3 on *scratch*> private "file://foo/y/z")
  w32-handle-dropped-file(#<window 3 on *scratch*> "\\\\foo\\y\\z")
  apply(w32-handle-dropped-file (#<window 3 on *scratch*> "\\\\foo\\y\\z"))
  #f(compiled-function (&rest args2) #<bytecode 0x15fd7ed>)("\\\\foo\\y\\z")
  mapc(#f(compiled-function (&rest args2) #<bytecode 0x15fd7ed>)
("\\\\foo\\y\\z"))
  w32-drag-n-drop((drag-n-drop (#<window 3 on *scratch*> 146 (304 . 67)
489947765 nil 146 (38 . 3) nil (304 . 19) (8 . 16)) ("\\\\foo\\y\\z")))
  funcall-interactively(w32-drag-n-drop (drag-n-drop (#<window 3 on
*scratch*> 146 (304 . 67) 489947765 nil 146 (38 . 3) nil (304 . 19) (8 .
16)) ("\\\\foo\\y\\z")))
  call-interactively(w32-drag-n-drop nil nil)
  command-execute(w32-drag-n-drop)