/* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API.
- Copyright (C) 1994-1995, 2000-2011 Free Software Foundation, Inc.
+ Copyright (C) 1994-1995, 2000-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <tlhelp32.h>
#include <psapi.h>
+#ifndef _MSC_VER
#include <w32api.h>
-#if !defined(__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
+#endif
+#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
/* This either is not in psapi.h or guarded by higher value of
_WIN32_WINNT than what we use. w32api supplied with MinGW 3.15
defines it in psapi.h */
read-only filesystem, like CD-ROM or a write-protected floppy.
The only way to be really sure is to actually create a file and
see if it succeeds. But I think that's too much to ask. */
+#ifdef _MSC_VER
+ /* MSVC's _access crashes with D_OK. */
+ if (tmp && sys_access (tmp, D_OK) == 0)
+#else
if (tmp && _access (tmp, D_OK) == 0)
+#endif
{
char * var = alloca (strlen (tmp) + 8);
sprintf (var, "TMPDIR=%s", tmp);
}
}
+ /* When Emacs is invoked with --no-site-lisp, we must remove the
+ site-lisp directories from the default value of EMACSLOADPATH.
+ This assumes that the site-lisp entries are at the front, and
+ that additional entries do exist. */
+ if (no_site_lisp)
+ {
+ for (i = 0; i < N_ENV_VARS; i++)
+ {
+ if (strcmp (env_vars[i].name, "EMACSLOADPATH") == 0)
+ {
+ char *site;
+ while ((site = strstr (env_vars[i].def_value, "site-lisp")))
+ env_vars[i].def_value = strchr (site, ';') + 1;
+ break;
+ }
+ }
+ }
+
#define SET_ENV_BUF_SIZE (4 * MAX_PATH) /* to cover EMACSLOADPATH */
/* Treat emacs_dir specially: set it unconditionally based on our
cv, /* To be filled later. */
#ifdef EMACSDEBUG
" --no-opt",
+#endif
+#ifdef ENABLE_CHECKING
+ " --enable-checking",
#endif
/* configure.bat already sets USER_CFLAGS and USER_LDFLAGS
with a starting space to save work here. */
{
BOOL result;
char temp[MAX_PATH];
+ int newname_dev;
+ int oldname_dev;
/* MoveFile on Windows 95 doesn't correctly change the short file name
alias in a number of circumstances (it is not easy to predict when
strcpy (temp, map_w32_filename (oldname, NULL));
+ /* volume_info is set indirectly by map_w32_filename. */
+ oldname_dev = volume_info.serialnum;
+
if (os_subtype == OS_WIN95)
{
char * o;
int i = 0;
oldname = map_w32_filename (oldname, NULL);
- if (o = strrchr (oldname, '\\'))
+ if ((o = strrchr (oldname, '\\')))
o++;
else
o = (char *) oldname;
- if (p = strrchr (temp, '\\'))
+ if ((p = strrchr (temp, '\\')))
p++;
else
p = temp;
all the permutations of shared or subst'd drives, etc.) */
newname = map_w32_filename (newname, NULL);
+
+ /* volume_info is set indirectly by map_w32_filename. */
+ newname_dev = volume_info.serialnum;
+
result = rename (temp, newname);
- if (result < 0
- && errno == EEXIST
- && _chmod (newname, 0666) == 0
- && _unlink (newname) == 0)
- result = rename (temp, newname);
+ if (result < 0)
+ {
+
+ if (errno == EACCES
+ && newname_dev != oldname_dev)
+ {
+ /* The implementation of `rename' on Windows does not return
+ errno = EXDEV when you are moving a directory to a
+ different storage device (ex. logical disk). It returns
+ EACCES instead. So here we handle such situations and
+ return EXDEV. */
+ DWORD attributes;
+
+ if ((attributes = GetFileAttributes (temp)) != -1
+ && attributes & FILE_ATTRIBUTE_DIRECTORY)
+ errno = EXDEV;
+ }
+ else if (errno == EEXIST)
+ {
+ if (_chmod (newname, 0666) != 0)
+ return result;
+ if (_unlink (newname) != 0)
+ return result;
+ result = rename (temp, newname);
+ }
+ }
return result;
}
unsigned hash;
/* Get the truly canonical filename, if it exists. (Note: this
- doesn't resolve aliasing due to subst commands, or recognise hard
+ doesn't resolve aliasing due to subst commands, or recognize hard
links. */
if (!w32_get_long_filename ((char *)name, fullname, MAX_PATH))
abort ();
FILE_FLAG_BACKUP_SEMANTICS, NULL))
!= INVALID_HANDLE_VALUE)
{
- /* This is more accurate in terms of gettting the correct number
+ /* This is more accurate in terms of getting the correct number
of links, but is quite slow (it is noticeable when Emacs is
making a list of file name completions). */
BY_HANDLE_FILE_INFORMATION info;
for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
{
CHECK_STRING_CAR (dlls);
- if (library_dll = LoadLibrary (SDATA (XCAR (dlls))))
+ if ((library_dll = LoadLibrary (SDATA (XCAR (dlls)))))
{
found = XCAR (dlls);
break;
it cannot find the Windows installation file. If this file does
not exist in the expected place, tell the user. */
- if (!noninteractive && !inhibit_window_system)
+ if (!noninteractive && !inhibit_window_system
+ /* Vload_path is not yet initialized when we are loading
+ loadup.el. */
+ && NILP (Vpurify_flag))
{
Lisp_Object objs[2];
Lisp_Object full_load_path;
void
init_ntproc (void)
{
- /* Initialise the socket interface now if available and requested by
+ /* Initialize the socket interface now if available and requested by
the user by defining PRELOAD_WINSOCK; otherwise loading will be
delayed until open-network-stream is called (w32-has-winsock can
also be used to dynamically load or reload winsock).
for (;;)
{
- n = sys_read(fd, (char*)buf, sz);
+ n = sys_read (fd, (char*)buf, sz);
if (n >= 0)
return n;
if (err == EWOULDBLOCK)
{
/* Set a small timeout. */
- EMACS_SET_SECS_USECS(timeout, 1, 0);
+ EMACS_SET_SECS_USECS (timeout, 1, 0);
FD_ZERO (&fdset);
FD_SET ((int)fd, &fdset);
{
struct Lisp_Process *process = (struct Lisp_Process *)p;
int fd = process->outfd;
- ssize_t n = sys_write(fd, buf, sz);
+ ssize_t n = sys_write (fd, buf, sz);
/* 0 or more bytes written means everything went fine. */
if (n >= 0)