aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/w32.c b/src/w32.c
index 94cf472a4ae..c8e16dfaa94 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -119,9 +119,10 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
119#include <aclapi.h> 119#include <aclapi.h>
120 120
121#ifdef _MSC_VER 121#ifdef _MSC_VER
122/* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER, except 122/* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER and the
123 on ntifs.h, which cannot be included because it triggers conflicts 123 associated macros, except on ntifs.h, which cannot be included
124 with other Windows API headers. So we define it here by hand. */ 124 because it triggers conflicts with other Windows API headers. So
125 we define it here by hand. */
125 126
126typedef struct _REPARSE_DATA_BUFFER { 127typedef struct _REPARSE_DATA_BUFFER {
127 ULONG ReparseTag; 128 ULONG ReparseTag;
@@ -149,6 +150,12 @@ typedef struct _REPARSE_DATA_BUFFER {
149 } DUMMYUNIONNAME; 150 } DUMMYUNIONNAME;
150} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; 151} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
151 152
153#define FILE_DEVICE_FILE_SYSTEM 9
154#define METHOD_BUFFERED 0
155#define FILE_ANY_ACCESS 0x00000000
156#define CTL_CODE(t,f,m,a) (((t)<<16)|((a)<<14)|((f)<<2)|(m))
157#define FSCTL_GET_REPARSE_POINT \
158 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
152#endif 159#endif
153 160
154/* TCP connection support. */ 161/* TCP connection support. */
@@ -172,7 +179,7 @@ typedef struct _REPARSE_DATA_BUFFER {
172#undef sendto 179#undef sendto
173 180
174#include "w32.h" 181#include "w32.h"
175#include "ndir.h" 182#include <dirent.h>
176#include "w32common.h" 183#include "w32common.h"
177#include "w32heap.h" 184#include "w32heap.h"
178#include "w32select.h" 185#include "w32select.h"
@@ -901,8 +908,18 @@ static char startup_dir[MAXPATHLEN];
901 908
902/* Get the current working directory. */ 909/* Get the current working directory. */
903char * 910char *
904getwd (char *dir) 911getcwd (char *dir, int dirsize)
905{ 912{
913 if (!dirsize)
914 {
915 errno = EINVAL;
916 return NULL;
917 }
918 if (dirsize <= strlen (startup_dir))
919 {
920 errno = ERANGE;
921 return NULL;
922 }
906#if 0 923#if 0
907 if (GetCurrentDirectory (MAXPATHLEN, dir) > 0) 924 if (GetCurrentDirectory (MAXPATHLEN, dir) > 0)
908 return dir; 925 return dir;
@@ -1818,7 +1835,7 @@ init_environment (char ** argv)
1818 memcpy (*envp, "COMSPEC=", 8); 1835 memcpy (*envp, "COMSPEC=", 8);
1819 } 1836 }
1820 1837
1821 /* Remember the initial working directory for getwd. */ 1838 /* Remember the initial working directory for getcwd. */
1822 /* FIXME: Do we need to resolve possible symlinks in startup_dir? 1839 /* FIXME: Do we need to resolve possible symlinks in startup_dir?
1823 Does it matter anywhere in Emacs? */ 1840 Does it matter anywhere in Emacs? */
1824 if (!GetCurrentDirectory (MAXPATHLEN, startup_dir)) 1841 if (!GetCurrentDirectory (MAXPATHLEN, startup_dir))
@@ -2431,7 +2448,7 @@ is_exec (const char * name)
2431 and readdir. We can't use the procedures supplied in sysdep.c, 2448 and readdir. We can't use the procedures supplied in sysdep.c,
2432 so we provide them here. */ 2449 so we provide them here. */
2433 2450
2434struct direct dir_static; /* simulated directory contents */ 2451struct dirent dir_static; /* simulated directory contents */
2435static HANDLE dir_find_handle = INVALID_HANDLE_VALUE; 2452static HANDLE dir_find_handle = INVALID_HANDLE_VALUE;
2436static int dir_is_fat; 2453static int dir_is_fat;
2437static char dir_pathname[MAXPATHLEN+1]; 2454static char dir_pathname[MAXPATHLEN+1];
@@ -2501,7 +2518,7 @@ closedir (DIR *dirp)
2501 xfree ((char *) dirp); 2518 xfree ((char *) dirp);
2502} 2519}
2503 2520
2504struct direct * 2521struct dirent *
2505readdir (DIR *dirp) 2522readdir (DIR *dirp)
2506{ 2523{
2507 int downcase = !NILP (Vw32_downcase_file_names); 2524 int downcase = !NILP (Vw32_downcase_file_names);
@@ -2555,7 +2572,7 @@ readdir (DIR *dirp)
2555 downcase = 1; /* 8+3 aliases are returned in all caps */ 2572 downcase = 1; /* 8+3 aliases are returned in all caps */
2556 } 2573 }
2557 dir_static.d_namlen = strlen (dir_static.d_name); 2574 dir_static.d_namlen = strlen (dir_static.d_name);
2558 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 + 2575 dir_static.d_reclen = sizeof (struct dirent) - MAXNAMLEN + 3 +
2559 dir_static.d_namlen - dir_static.d_namlen % 4; 2576 dir_static.d_namlen - dir_static.d_namlen % 4;
2560 2577
2561 /* If the file name in cFileName[] includes `?' characters, it means 2578 /* If the file name in cFileName[] includes `?' characters, it means