diff options
| author | Kenichi Handa | 2012-11-23 23:36:24 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-11-23 23:36:24 +0900 |
| commit | 2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9 (patch) | |
| tree | 3711b97807201b7eeaa066003b1c3a4ce929e5bb /src/w32.c | |
| parent | e1d276cbf9e18f13101328f56bed1a1c0a66e63a (diff) | |
| parent | e7d0e5ee247a155a268ffbf80bedbe25e15b5032 (diff) | |
| download | emacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.tar.gz emacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.zip | |
Diffstat (limited to 'src/w32.c')
| -rw-r--r-- | src/w32.c | 35 |
1 files changed, 26 insertions, 9 deletions
| @@ -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 | ||
| 126 | typedef struct _REPARSE_DATA_BUFFER { | 127 | typedef 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. */ |
| 903 | char * | 910 | char * |
| 904 | getwd (char *dir) | 911 | getcwd (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 | ||
| 2434 | struct direct dir_static; /* simulated directory contents */ | 2451 | struct dirent dir_static; /* simulated directory contents */ |
| 2435 | static HANDLE dir_find_handle = INVALID_HANDLE_VALUE; | 2452 | static HANDLE dir_find_handle = INVALID_HANDLE_VALUE; |
| 2436 | static int dir_is_fat; | 2453 | static int dir_is_fat; |
| 2437 | static char dir_pathname[MAXPATHLEN+1]; | 2454 | static char dir_pathname[MAXPATHLEN+1]; |
| @@ -2501,7 +2518,7 @@ closedir (DIR *dirp) | |||
| 2501 | xfree ((char *) dirp); | 2518 | xfree ((char *) dirp); |
| 2502 | } | 2519 | } |
| 2503 | 2520 | ||
| 2504 | struct direct * | 2521 | struct dirent * |
| 2505 | readdir (DIR *dirp) | 2522 | readdir (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 |