From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Toru TSUNEYOSHI" Newsgroups: gmane.emacs.devel Subject: patch about moving file (or directory) to the Recycle Bin on Windows NT series Date: Tue, 22 Apr 2008 02:07:56 +0900 Message-ID: References: <480CC2D7.3030302@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0014_01C8A41D.AE115F00" X-Trace: ger.gmane.org 1208799064 21131 80.91.229.12 (21 Apr 2008 17:31:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2008 17:31:04 +0000 (UTC) Cc: "Lennart Borgman \(gmail\)" To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 21 19:31:36 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jnzqp-00057h-Tb for ged-emacs-devel@m.gmane.org; Mon, 21 Apr 2008 19:30:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jnzq3-0006QM-NS for ged-emacs-devel@m.gmane.org; Mon, 21 Apr 2008 13:29:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JnzV5-00021g-Ee for emacs-devel@gnu.org; Mon, 21 Apr 2008 13:08:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JnzUw-00020B-Ky for emacs-devel@gnu.org; Mon, 21 Apr 2008 13:08:18 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JnzUw-000208-BS for emacs-devel@gnu.org; Mon, 21 Apr 2008 13:08:10 -0400 Original-Received: from bay0-omc1-s3.bay0.hotmail.com ([65.54.246.75]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JnzUt-0000wC-08 for emacs-devel@gnu.org; Mon, 21 Apr 2008 13:08:10 -0400 Original-Received: from hotmail.com ([207.46.10.14]) by bay0-omc1-s3.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 21 Apr 2008 10:08:00 -0700 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 21 Apr 2008 10:08:01 -0700 Original-Received: from 124.155.30.210 by BAY121-DAV4.phx.gbl with DAV; Mon, 21 Apr 2008 17:07:57 +0000 X-Originating-IP: [124.155.30.210] X-Originating-Email: [t_tuneyosi@hotmail.com] X-Sender: t_tuneyosi@hotmail.com X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 X-OriginalArrivalTime: 21 Apr 2008 17:08:01.0052 (UTC) FILETIME=[41169DC0:01C8A3D2] X-detected-kernel: by monty-python.gnu.org: Windows 2000 SP4, XP SP1+ X-Mailman-Approved-At: Mon, 21 Apr 2008 13:28:28 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:95660 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C8A41D.AE115F00 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit I made a patch for src/{w32.c,emacs.c} (in emacs 22.2) about moving file (or directory) to the Recycle Bin on Windows NT series. If possible, please patch emacs source. ------=_NextPart_000_0014_01C8A41D.AE115F00 Content-Type: application/octet-stream; name="w32.c_and_emacs.c.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="w32.c_and_emacs.c.diff" --- w32.c.original 2008-02-23 22:49:09.000000000 +0900=0A= +++ w32.c 2008-04-21 22:08:48.248179300 +0900=0A= @@ -75,6 +75,10 @@=0A= #include =0A= #include =0A= =0A= +#ifdef MYDEF=0A= +#include =0A= +#endif /* MYDEF */=0A= +=0A= #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */=0A= #include =0A= #undef socket=0A= @@ -111,6 +115,10 @@=0A= extern Lisp_Object Vw32_get_true_file_attributes;=0A= extern int w32_num_mouse_buttons;=0A= =0A= +#ifdef MYDEF=0A= +int w32_sys_unlink_use_shellapi;=0A= +#endif /* MYDEF */=0A= +=0A= =0C=0A= /*=0A= Initialization states=0A= @@ -2240,6 +2248,71 @@=0A= return result;=0A= }=0A= =0A= +#ifdef MYDEF=0A= +=0A= +int=0A= +sys_rmdir (const char * path)=0A= +{=0A= + if (w32_sys_unlink_use_shellapi)=0A= + return (sys_unlink ((const char *)path));=0A= + else=0A= + return _rmdir (map_w32_filename (path, NULL));=0A= +}=0A= +=0A= +int=0A= +sys_unlink (const char * path)=0A= +{=0A= + if (w32_sys_unlink_use_shellapi)=0A= + {=0A= + /* Each file name must be terminated by a single NULL=0A= + character. An additional NULL character must be appended to the=0A= + end of the final name to indicate the end of pFrom. */=0A= + TCHAR tmp_path[MAX_PATH + 1 + 1];=0A= + SHFILEOPSTRUCT stFileOp;=0A= +=0A= + path =3D map_w32_filename (path, NULL);=0A= +=0A= + /* On Unix, unlink works without write permission. */=0A= + _chmod (path, 0666);=0A= +=0A= +#if 0=0A= + *(tmp_path + lstrlen(tmp_path) + 1) =3D '\0';=0A= +#else=0A= + ZeroMemory(tmp_path, sizeof(tmp_path));=0A= +#endif=0A= + lstrcpy(tmp_path, path);=0A= +=0A= + ZeroMemory(&stFileOp, sizeof(SHFILEOPSTRUCT));=0A= + stFileOp.hwnd =3D HWND_DESKTOP;=0A= + stFileOp.wFunc =3D FO_DELETE;=0A= + stFileOp.pFrom =3D tmp_path;=0A= + stFileOp.pTo =3D NULL;=0A= + stFileOp.fFlags =3D FOF_ALLOWUNDO | FOF_NOCONFIRMATION | = FOF_SILENT;=0A= + stFileOp.fAnyOperationsAborted =3D FALSE;=0A= + stFileOp.hNameMappings =3D NULL;=0A= + stFileOp.lpszProgressTitle =3D NULL;=0A= +=0A= +#if 0=0A= + SHFileOperation(&stFileOp);=0A= +=0A= + return (stFileOp.fAnyOperationsAborted);=0A= +#else=0A= + /* value returned by SHFileOperation() must match value returned = by _unlink() */=0A= + return (SHFileOperation(&stFileOp) =3D=3D 0 ? 0 : -1);=0A= +#endif=0A= + }=0A= + else=0A= + {=0A= + path =3D map_w32_filename (path, NULL);=0A= +=0A= + /* On Unix, unlink works without write permission. */=0A= + _chmod (path, 0666);=0A= + return _unlink (path);=0A= + }=0A= +}=0A= +=0A= +#else /* MYDEF */=0A= +=0A= int=0A= sys_rmdir (const char * path)=0A= {=0A= @@ -2256,6 +2329,8 @@=0A= return _unlink (path);=0A= }=0A= =0A= +#endif /* MYDEF */=0A= +=0A= static FILETIME utc_base_ft;=0A= static long double utc_base;=0A= static int init =3D 0;=0A= @@ -4160,6 +4235,18 @@=0A= SetConsoleCtrlHandler(shutdown_handler, TRUE);=0A= }=0A= =0A= +#ifdef MYDEF=0A= +=0A= +void=0A= +syms_of_w32 ()=0A= +{=0A= + DEFVAR_BOOL ("w32-sys-unlink-use-shellapi", = &w32_sys_unlink_use_shellapi,=0A= + "Non-nil means using shellapi for sys_unlink(), sys_rmdir().");=0A= + w32_sys_unlink_use_shellapi =3D 0;=0A= +}=0A= +=0A= +#endif /* MYDEF */=0A= +=0A= /* end of w32.c */=0A= =0A= /* arch-tag: 90442dd3-37be-482b-b272-ac752e3049f1=0A= --- emacs.c.original 2008-01-10 21:16:14.000000000 +0900=0A= +++ emacs.c 2008-04-21 22:14:55.457184200 +0900=0A= @@ -1588,6 +1588,9 @@=0A= syms_of_vmsproc ();=0A= #endif /* VMS */=0A= #ifdef WINDOWSNT=0A= +#ifdef MYDEF=0A= + syms_of_w32 ();=0A= +#endif /* MYDEF */=0A= syms_of_ntproc ();=0A= #endif /* WINDOWSNT */=0A= syms_of_window ();=0A= ------=_NextPart_000_0014_01C8A41D.AE115F00--