comparison src/event-msw.c @ 2526:902d5bd9b75c

[xemacs-hg @ 2005-01-28 02:36:11 by ben] Support symlinks under Windows nt.c, fileio.c: Fix sync comments. config.h.in, dired-msw.c, emacs.c, event-msw.c, fileio.c, glyphs.c, lisp.h, nt.c, process-nt.c, realpath.c, sound.c, symsinit.h, sysdep.c, sysfile.h, syswindows.h, win32.c: Add support for treating shortcuts under Windows as symbolic links. Enabled with mswindows-shortcuts-are-links (t by default). Rewrite lots of places to use PATHNAME_CONVERT_OUT, which is moved to sysfile.h. Add PATHNAME_RESOLVE_LINKS, which only does things under Windows. Add profiling section for expand_file_name calls. nt.c, sysdep.c: Unicode-ize. realpath.c: Renamed from readlink_and_correct_case. Fix some problems with Windows implementation due to incorrect understanding of workings of the function. sound.c, ntplay.c, sound.h: Rename play_sound_file to nt_play_sound_file and pass internally-formatted data to it to avoid converting out and back again. text.h: is_c -> is_ascii.
author ben
date Fri, 28 Jan 2005 02:36:28 +0000
parents 3d8143fc88e1
children a25c824ed558
comparison
equal deleted inserted replaced
2525:52f00344a629 2526:902d5bd9b75c
3710 { 3710 {
3711 Ibyte *fname; 3711 Ibyte *fname;
3712 Extbyte *fname_ext; 3712 Extbyte *fname_ext;
3713 Bytecount fnamelen; 3713 Bytecount fnamelen;
3714 Charcount len = qxeDragQueryFile ((HDROP) wParam, i, NULL, 0); 3714 Charcount len = qxeDragQueryFile ((HDROP) wParam, i, NULL, 0);
3715 int freeme = 0;
3715 /* The URLs that we make here aren't correct according to section 3716 /* The URLs that we make here aren't correct according to section
3716 * 3.10 of rfc1738 because they're missing the //<host>/ part and 3717 * 3.10 of rfc1738 because they're missing the //<host>/ part and
3717 * because they may contain reserved characters. But that's OK - 3718 * because they may contain reserved characters. But that's OK -
3718 * they just need to be good enough to keep dragdrop.el happy. */ 3719 * they just need to be good enough to keep dragdrop.el happy. */
3719 fname_ext = alloca_extbytes ((len + 1) * XETCHAR_SIZE); 3720 fname_ext = alloca_extbytes ((len + 1) * XETCHAR_SIZE);
3721 3722
3722 TO_INTERNAL_FORMAT (DATA, (fname_ext, len * XETCHAR_SIZE), 3723 TO_INTERNAL_FORMAT (DATA, (fname_ext, len * XETCHAR_SIZE),
3723 ALLOCA, (fname, fnamelen), 3724 ALLOCA, (fname, fnamelen),
3724 Qmswindows_tstr); 3725 Qmswindows_tstr);
3725 3726
3727
3726 /* May be a shell link aka "shortcut" - replace fname if so */ 3728 /* May be a shell link aka "shortcut" - replace fname if so */
3727 #if !defined (NO_CYGWIN_COM_SUPPORT)
3728 if (!qxestrcasecmp_ascii (fname + fnamelen - 4, ".LNK")) 3729 if (!qxestrcasecmp_ascii (fname + fnamelen - 4, ".LNK"))
3729 { 3730 {
3730 /* #### 3731 fname = mswindows_read_link (fname);
3731 3732 freeme = 1;
3732 Note the following in the docs:
3733
3734 Note: The IShellLink interface has an ANSI version
3735 (IShellLinkA) and a Unicode version (IShellLinkW). The
3736 version that will be used depends on whether you compile
3737 for ANSI or Unicode. However, Microsoft® Windows 95 and
3738 Microsoft® Windows 98 only support IShellLinkA.
3739
3740 We haven't yet implemented COM support in the
3741 Unicode-splitting library. I don't quite understand how
3742 COM works yet, but it looks like what's happening is
3743 that the ShellLink class implements both the IShellLinkA
3744 and IShellLinkW interfaces. To make this work at
3745 run-time, we have to do something like this:
3746
3747 -- define a new interface qxeIShellLink that uses
3748 Extbyte * instead of LPSTR or LPWSTR. (not totally
3749 necessary since Extbyte * == LPSTR).
3750
3751 -- define a new class qxeShellLink that implements
3752 qxeIShellLink. the methods on this class need to create
3753 a shadow ShellLink object to do all the real work, and
3754 call the corresponding function from either the
3755 IShellLinkA or IShellLinkW interfaces on this object,
3756 depending on whether XEUNICODE_P is defined.
3757
3758 -- with appropriate preprocessor magic, of course, we
3759 could make things appear transparent; but we've decided
3760 not to do preprocessor magic for the moment.
3761 */
3762
3763 /* #### Not Unicode-split for the moment; we have to do it
3764 ourselves. */
3765 if (XEUNICODE_P)
3766 {
3767 IShellLinkW *psl;
3768
3769 if (CoCreateInstance (
3770 XECOMID (CLSID_ShellLink),
3771 NULL,
3772 CLSCTX_INPROC_SERVER,
3773 XECOMID (IID_IShellLinkW),
3774 &VOIDP_CAST (psl)) == S_OK)
3775 {
3776 IPersistFile *ppf;
3777
3778 if (XECOMCALL2 (psl, QueryInterface,
3779 XECOMID (IID_IPersistFile),
3780 &VOIDP_CAST (ppf)) == S_OK)
3781 {
3782 Extbyte *fname_unicode;
3783 WIN32_FIND_DATAW wfd;
3784 LPWSTR resolved =
3785 alloca_array (WCHAR, PATH_MAX_EXTERNAL + 1);
3786
3787 TO_EXTERNAL_FORMAT (DATA, (fname, fnamelen),
3788 C_STRING_ALLOCA,
3789 fname_unicode,
3790 Qmswindows_unicode);
3791
3792 if (XECOMCALL2 (ppf, Load,
3793 (LPWSTR) fname_unicode,
3794 STGM_READ) == S_OK &&
3795 /* #### YUCK! Docs read
3796
3797 cchMaxPath
3798
3799 Maximum number of bytes to copy to the buffer pointed to by the
3800 pszFile parameter.
3801
3802 But "cch" means "count of characters", not bytes. I'll assume the doc
3803 writers messed up and the programmer was correct. Also, this approach
3804 is safe even if it's actually the other way around. */
3805 #if defined (CYGWIN_HEADERS) && W32API_INSTALLED_VER < W32API_VER(2,2)
3806 /* Another Cygwin prototype error,
3807 fixed in v2.2 of w32api */
3808 XECOMCALL4 (psl, GetPath, (LPSTR) resolved,
3809 PATH_MAX_EXTERNAL, &wfd, 0)
3810 #else
3811 XECOMCALL4 (psl, GetPath, resolved,
3812 PATH_MAX_EXTERNAL, &wfd, 0)
3813 #endif
3814 == S_OK)
3815 TO_INTERNAL_FORMAT (C_STRING, resolved,
3816 ALLOCA, (fname, fnamelen),
3817 Qmswindows_tstr);
3818
3819 XECOMCALL0 (ppf, Release);
3820 }
3821
3822 XECOMCALL0 (psl, Release);
3823 }
3824 }
3825 else
3826 {
3827 IShellLinkA *psl;
3828
3829 if (CoCreateInstance (
3830 XECOMID (CLSID_ShellLink),
3831 NULL,
3832 CLSCTX_INPROC_SERVER,
3833 XECOMID (IID_IShellLinkA),
3834 &VOIDP_CAST (psl)) == S_OK)
3835 {
3836 IPersistFile *ppf;
3837
3838 if (XECOMCALL2 (psl, QueryInterface,
3839 XECOMID (IID_IPersistFile),
3840 &VOIDP_CAST (ppf)) == S_OK)
3841 {
3842 Extbyte *fname_unicode;
3843 WIN32_FIND_DATAA wfd;
3844 LPSTR resolved =
3845 alloca_array (CHAR, PATH_MAX_EXTERNAL + 1);
3846
3847 /* Always Unicode. Not obvious from the
3848 IPersistFile documentation, but look under
3849 "Shell Link" for example code. */
3850 TO_EXTERNAL_FORMAT (DATA, (fname, fnamelen),
3851 C_STRING_ALLOCA,
3852 fname_unicode,
3853 Qmswindows_unicode);
3854
3855 if (XECOMCALL2 (ppf, Load,
3856 (LPWSTR) fname_unicode,
3857 STGM_READ) == S_OK
3858 && XECOMCALL4 (psl, GetPath, resolved,
3859 PATH_MAX_EXTERNAL, &wfd, 0) == S_OK)
3860 TO_INTERNAL_FORMAT (C_STRING, resolved,
3861 ALLOCA, (fname, fnamelen),
3862 Qmswindows_tstr);
3863
3864 XECOMCALL0 (ppf, Release);
3865 }
3866
3867 XECOMCALL0 (psl, Release);
3868 }
3869 }
3870 } 3733 }
3871 #endif /* !defined (NO_CYGWIN_COM_SUPPORT) */ 3734
3872 { 3735 {
3873 fname = urlify_filename (fname); 3736 Ibyte *fname2 = urlify_filename (fname);
3874 l_item = build_intstring (fname); 3737 l_item = build_intstring (fname2);
3875 xfree (fname, Ibyte *); 3738 xfree (fname2, Ibyte *);
3739 if (freeme)
3740 xfree (fname, Ibyte *);
3876 l_dndlist = Fcons (l_item, l_dndlist); 3741 l_dndlist = Fcons (l_item, l_dndlist);
3877 } 3742 }
3878 } 3743 }
3879 3744
3880 DragFinish ((HDROP) wParam); 3745 DragFinish ((HDROP) wParam);