/[emacs]/emacs/src/w32.c
ViewVC logotype

Diff of /emacs/src/w32.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.94 by lute, Mon Jul 4 16:06:35 2005 UTC revision 1.95 by jasonr, Thu Jul 14 22:31:57 2005 UTC
# Line 20  Boston, MA 02110-1301, USA. Line 20  Boston, MA 02110-1301, USA.
20    
21     Geoff Voelker (voelker@cs.washington.edu)                         7-29-94     Geoff Voelker (voelker@cs.washington.edu)                         7-29-94
22  */  */
   
   
23  #include <stddef.h> /* for offsetof */  #include <stddef.h> /* for offsetof */
24  #include <stdlib.h>  #include <stdlib.h>
25  #include <stdio.h>  #include <stdio.h>
# Line 73  Boston, MA 02110-1301, USA. Line 71  Boston, MA 02110-1301, USA.
71  #define _ANONYMOUS_STRUCT  #define _ANONYMOUS_STRUCT
72  #endif  #endif
73  #include <windows.h>  #include <windows.h>
74    #include <shlobj.h>
75    
76  #ifdef HAVE_SOCKETS     /* TCP connection support, if kernel can do it */  #ifdef HAVE_SOCKETS     /* TCP connection support, if kernel can do it */
77  #include <sys/socket.h>  #include <sys/socket.h>
# Line 100  Boston, MA 02110-1301, USA. Line 99  Boston, MA 02110-1301, USA.
99  #include "w32heap.h"  #include "w32heap.h"
100  #include "systime.h"  #include "systime.h"
101    
102    typedef HRESULT (WINAPI * ShGetFolderPath_fn)
103      (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
104    
105  void globals_of_w32 ();  void globals_of_w32 ();
106    
107  extern Lisp_Object Vw32_downcase_file_names;  extern Lisp_Object Vw32_downcase_file_names;
# Line 903  init_environment (char ** argv) Line 905  init_environment (char ** argv)
905    static const char * const tempdirs[] = {    static const char * const tempdirs[] = {
906      "$TMPDIR", "$TEMP", "$TMP", "c:/"      "$TMPDIR", "$TEMP", "$TMP", "c:/"
907    };    };
908    
909    int i;    int i;
910    
911    const int imax = sizeof (tempdirs) / sizeof (tempdirs[0]);    const int imax = sizeof (tempdirs) / sizeof (tempdirs[0]);
912    
913    /* Make sure they have a usable $TMPDIR.  Many Emacs functions use    /* Make sure they have a usable $TMPDIR.  Many Emacs functions use
# Line 942  init_environment (char ** argv) Line 946  init_environment (char ** argv)
946      LPBYTE lpval;      LPBYTE lpval;
947      DWORD dwType;      DWORD dwType;
948      char locale_name[32];      char locale_name[32];
949        struct stat ignored;
950        char default_home[MAX_PATH];
951    
952      static struct env_entry      static struct env_entry
953      {      {
# Line 964  init_environment (char ** argv) Line 970  init_environment (char ** argv)
970        {"LANG", NULL},        {"LANG", NULL},
971      };      };
972    
973        /* For backwards compatibility, check if a .emacs file exists in C:/
974           If not, then we can try to default to the appdata directory under the
975           user's profile, which is more likely to be writable.   */
976        if (stat ("C:/.emacs", &ignored) < 0)
977        {
978          HRESULT profile_result;
979          /* Dynamically load ShGetFolderPath, as it won't exist on versions
980             of Windows 95 and NT4 that have not been updated to include
981             MSIE 5.  Also we don't link with shell32.dll by default.  */
982          HMODULE shell32_dll;
983          ShGetFolderPath_fn get_folder_path;
984          shell32_dll = GetModuleHandle ("shell32.dll");
985          get_folder_path = (ShGetFolderPath_fn)
986            GetProcAddress (shell32_dll, "SHGetFolderPathA");
987    
988          if (get_folder_path != NULL)
989            {
990              profile_result = get_folder_path (NULL, CSIDL_APPDATA, NULL,
991                                                0, default_home);
992    
993              /* If we can't get the appdata dir, revert to old behaviour.  */
994              if (profile_result == S_OK)
995                env_vars[0].def_value = default_home;
996            }
997    
998          /* Unload shell32.dll, it is not needed anymore.  */
999          FreeLibrary (shell32_dll);
1000        }
1001    
1002    /* Get default locale info and use it for LANG.  */    /* Get default locale info and use it for LANG.  */
1003    if (GetLocaleInfo (LOCALE_USER_DEFAULT,    if (GetLocaleInfo (LOCALE_USER_DEFAULT,
1004                       LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,                       LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.95

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26