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: Re: patch about moving file (or directory) to the Recycle Bin on Windows NT series Date: Tue, 22 Apr 2008 06:32:12 +0900 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0031_01C8A442.994C4B50" X-Trace: ger.gmane.org 1208834396 4146 80.91.229.12 (22 Apr 2008 03:19:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Apr 2008 03:19:56 +0000 (UTC) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 22 05:20:31 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 1Jo93F-0004rQ-VZ for ged-emacs-devel@m.gmane.org; Tue, 22 Apr 2008 05:20:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jo91v-0002VM-RH for ged-emacs-devel@m.gmane.org; Mon, 21 Apr 2008 23:18:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jo3cr-00087o-8q for emacs-devel@gnu.org; Mon, 21 Apr 2008 17:32:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jo3cm-00086Q-ES for emacs-devel@gnu.org; Mon, 21 Apr 2008 17:32:36 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jo3cm-00086J-1p for emacs-devel@gnu.org; Mon, 21 Apr 2008 17:32:32 -0400 Original-Received: from bay0-omc3-s25.bay0.hotmail.com ([65.54.246.225]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jo3ci-00039L-HR for emacs-devel@gnu.org; Mon, 21 Apr 2008 17:32:31 -0400 Original-Received: from hotmail.com ([207.46.10.17]) by bay0-omc3-s25.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 21 Apr 2008 14:32:17 -0700 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 21 Apr 2008 14:32:17 -0700 Original-Received: from 124.155.30.210 by BAY121-DAV7.phx.gbl with DAV; Mon, 21 Apr 2008 21:32:14 +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 21:32:17.0724 (UTC) FILETIME=[2C66BFC0:01C8A3F7] X-detected-kernel: by monty-python.gnu.org: Windows 2000 SP4, XP SP1+ X-Mailman-Approved-At: Mon, 21 Apr 2008 23:16:53 -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:95729 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C8A442.994C4B50 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit I made a revised edition (including w32.h). ------=_NextPart_000_0031_01C8A442.994C4B50 Content-Type: application/octet-stream; name="w32.h_w32.c_emacs.c.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="w32.h_w32.c_emacs.c.diff" --- w32.h.original 2008-01-10 21:16:16.000000000 +0900=0A= +++ w32.h 2008-04-22 05:52:24.056379500 +0900=0A= @@ -129,6 +129,9 @@=0A= =0A= extern void init_ntproc (void);=0A= extern void term_ntproc (void);=0A= +#ifdef W32_SYS_UNLINK_USE_SHELLAPI=0A= +extern void syms_of_w32 (void);=0A= +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */=0A= extern void globals_of_w32 (void);=0A= extern void syms_of_w32term (void);=0A= extern void syms_of_w32fns (void);=0A= --- w32.c.original 2008-02-23 22:49:09.000000000 +0900=0A= +++ w32.c 2008-04-22 05:51:43.056197700 +0900=0A= @@ -75,6 +75,10 @@=0A= #include =0A= #include =0A= =0A= +#ifdef W32_SYS_UNLINK_USE_SHELLAPI=0A= +#include =0A= +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */=0A= +=0A= #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */=0A= #include =0A= #undef socket=0A= @@ -104,6 +108,9 @@=0A= typedef HRESULT (WINAPI * ShGetFolderPath_fn)=0A= (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);=0A= =0A= +#ifdef W32_SYS_UNLINK_USE_SHELLAPI=0A= +void syms_of_w32 ();=0A= +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */=0A= void globals_of_w32 ();=0A= =0A= extern Lisp_Object Vw32_downcase_file_names;=0A= @@ -111,6 +118,10 @@=0A= extern Lisp_Object Vw32_get_true_file_attributes;=0A= extern int w32_num_mouse_buttons;=0A= =0A= +#ifdef W32_SYS_UNLINK_USE_SHELLAPI=0A= +int w32_sys_unlink_use_shellapi;=0A= +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */=0A= +=0A= =0C=0A= /*=0A= Initialization states=0A= @@ -2240,6 +2251,71 @@=0A= return result;=0A= }=0A= =0A= +#ifdef W32_SYS_UNLINK_USE_SHELLAPI=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 /* W32_SYS_UNLINK_USE_SHELLAPI */=0A= +=0A= int=0A= sys_rmdir (const char * path)=0A= {=0A= @@ -2256,6 +2332,8 @@=0A= return _unlink (path);=0A= }=0A= =0A= +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */=0A= +=0A= static FILETIME utc_base_ft;=0A= static long double utc_base;=0A= static int init =3D 0;=0A= @@ -4160,6 +4238,18 @@=0A= SetConsoleCtrlHandler(shutdown_handler, TRUE);=0A= }=0A= =0A= +#ifdef W32_SYS_UNLINK_USE_SHELLAPI=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 1;=0A= +}=0A= +=0A= +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */=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-22 05:49:48.407912100 +0900=0A= @@ -1588,6 +1588,9 @@=0A= syms_of_vmsproc ();=0A= #endif /* VMS */=0A= #ifdef WINDOWSNT=0A= +#ifdef W32_SYS_UNLINK_USE_SHELLAPI=0A= + syms_of_w32 ();=0A= +#endif /* W32_SYS_UNLINK_USE_SHELLAPI */=0A= syms_of_ntproc ();=0A= #endif /* WINDOWSNT */=0A= syms_of_window ();=0A= ------=_NextPart_000_0031_01C8A442.994C4B50--