From: Eli Zaretskii <eliz@gnu.org>
To: Toru TSUNEYOSHI <t_tuneyosi@hotmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: patch about moving file (or directory) to the Recycle Bin on Windows NT series
Date: Tue, 22 Apr 2008 21:19:09 +0300 [thread overview]
Message-ID: <uiqy9ah2a.fsf@gnu.org> (raw)
In-Reply-To: <BAY121-DAV7DE6B9E705C69F9DBCF13E2E10@phx.gbl>
> From: "Toru TSUNEYOSHI" <t_tuneyosi@hotmail.com>
> Date: Tue, 22 Apr 2008 06:32:12 +0900
>
> I made a revised edition (including w32.h).
Thank you.
I think this contribution is large enough to require legal papers, but
I'll let Stefan and Yidong decide that.
> +#ifdef W32_SYS_UNLINK_USE_SHELLAPI
> +extern void syms_of_w32 (void);
> +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */
If we are going to support this feature, we don't need this
conditional compilation, so please remove the #ifdef's (here and
everywhere else).
> + if (w32_sys_unlink_use_shellapi)
> + {
> + /* Each file name must be terminated by a single NULL
> + character. An additional NULL character must be appended to the
> + end of the final name to indicate the end of pFrom. */
> + TCHAR tmp_path[MAX_PATH + 1 + 1];
AFAIU from the Microsoft documentation, there's no need for the second
"+1", as MAX_PATH already accounts for one terminating null character.
> + SHFILEOPSTRUCT stFileOp;
> +
> + path = map_w32_filename (path, NULL);
MSDN advises to use only absolute file names with SHFileOperation,
otherwise they say that recycling will not work (see
http://msdn2.microsoft.com/en-us/library/bb759795(VS.85).aspx for the
details). So I think we need to make the file name absolute here.
> + /* On Unix, unlink works without write permission. */
> + _chmod (path, 0666);
Can this somehow leave the file writable without deleting it, if the
code is interrupted before it gets to undo this _chmod call? If so,
we need to guard against that somehow.
> + ZeroMemory(&stFileOp, sizeof(SHFILEOPSTRUCT));
> + stFileOp.hwnd = HWND_DESKTOP;
> + stFileOp.wFunc = FO_DELETE;
> + stFileOp.pFrom = tmp_path;
> + stFileOp.pTo = NULL;
> + stFileOp.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_SILENT;
Do we want to use the FOF_NO_CONNECTED_ELEMENTS flag here? Deleting
connected files, which is the default with shell API, is not what
happens with the normal unlink, is it? So it might surprise the user
if we do that when using the shell API.
How about FOF_NOERRORUI? do we want it? I understand that without it,
a dialog will be presented to the user in case of any errors during
the deletion.
> + /* value returned by SHFileOperation() must match value returned by _unlink() */
> + return (SHFileOperation(&stFileOp) == 0 ? 0 : -1);
Do we want to set errno here, at least for some popular reasons that
fail the deletion, using the DE_* error codes documented on the MSDN?
The caller of this function may wish to look at errno and provide
diagnostics.
> +void
> +syms_of_w32 ()
> +{
> + DEFVAR_BOOL ("w32-sys-unlink-use-shellapi", &w32_sys_unlink_use_shellapi,
> + "Non-nil means using shellapi for sys_unlink(), sys_rmdir().");
> + w32_sys_unlink_use_shellapi = 1;
> +}
Please use a more descriptive name, such as w32-delete-to-recycle-bin
or something similar. The point is that the name should tell a user
what this option will do, not which API it will use. (I imagine that
many Emacs users don't even know what is the shell API.)
Also, please make this option off by default.
In addition, we need an entry for NEWS about this new feature. Could
you please write it?
Finally, using this feature requires to add -lshellapi to the linker
switches in nt/?make.defs, right? Or is that linked in by default?
Thanks again for working on this.
next prev parent reply other threads:[~2008-04-22 18:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-21 21:32 patch about moving file (or directory) to the Recycle Bin on Windows NT series Toru TSUNEYOSHI
2008-04-22 9:02 ` Toru TSUNEYOSHI
2008-04-22 15:47 ` Stefan Monnier
2008-04-22 17:04 ` Eli Zaretskii
2008-04-22 18:24 ` Eli Zaretskii
2008-04-22 18:19 ` Eli Zaretskii [this message]
2008-04-22 20:58 ` Jason Rumney
2008-04-23 1:15 ` Stefan Monnier
2008-04-23 1:14 ` Stefan Monnier
2008-04-23 4:55 ` Eli Zaretskii
2008-04-23 16:45 ` Toru TSUNEYOSHI
2008-04-23 15:35 ` Stefan Monnier
2008-04-25 20:18 ` Toru TSUNEYOSHI
-- strict thread matches above, loose matches on Subject: below --
2008-05-27 17:11 Toru TSUNEYOSHI
2008-05-27 18:39 ` Stefan Monnier
2008-04-25 21:10 Toru TSUNEYOSHI
2008-04-26 7:25 ` Eli Zaretskii
2008-04-30 15:00 ` Toru TSUNEYOSHI
2008-05-15 17:36 ` Stefan Monnier
2008-05-25 0:07 ` Toru TSUNEYOSHI
2008-05-25 1:24 ` Stefan Monnier
2008-05-25 9:59 ` Jason Rumney
2008-05-25 11:22 ` Stefan Monnier
2008-04-21 14:25 patch is received? Toru TSUNEYOSHI
2008-04-21 16:37 ` Lennart Borgman (gmail)
2008-04-21 17:07 ` patch about moving file (or directory) to the Recycle Bin on Windows NT series Toru TSUNEYOSHI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uiqy9ah2a.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=t_tuneyosi@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.