aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorEli Zaretskii2015-08-31 17:48:26 +0300
committerEli Zaretskii2015-08-31 17:48:26 +0300
commit697be62c5f2b86e8ad93dfcaa0df07890c24d989 (patch)
tree5e6b5d4ea9cd75bbc2eca0d7831b1364b6bc333a /src/fileio.c
parent8af8355c3f72500986f6f10b62714b228d6f35ee (diff)
downloademacs-697be62c5f2b86e8ad93dfcaa0df07890c24d989.tar.gz
emacs-697be62c5f2b86e8ad93dfcaa0df07890c24d989.zip
Make file-accessible-directory-p reliable on MS-Windows
* src/w32.c (w32_accessible_directory_p): New function. * src/w32.h (w32_accessible_directory_p): Add prototype. * src/fileio.c (file_accessible_directory_p) [WINDOWSNT]: Call w32_accessible_directory_p to test a directory for accessibility by the current user. (Bug#21346) (Ffile_accessible_directory_p): Remove the w32 specific caveat from the doc string.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/fileio.c b/src/fileio.c
index debd1f30a4f..a36dfbcfa36 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2655,11 +2655,7 @@ and the directory must allow you to open files in it. In order to use a
2655directory as a buffer's current directory, this predicate must return true. 2655directory as a buffer's current directory, this predicate must return true.
2656A directory name spec may be given instead; then the value is t 2656A directory name spec may be given instead; then the value is t
2657if the directory so specified exists and really is a readable and 2657if the directory so specified exists and really is a readable and
2658searchable directory. 2658searchable directory. */)
2659
2660The result might be a false positive on MS-Windows in some rare cases,
2661i.e., this function could return t for a directory that is not
2662accessible by the current user. */)
2663 (Lisp_Object filename) 2659 (Lisp_Object filename)
2664{ 2660{
2665 Lisp_Object absname; 2661 Lisp_Object absname;
@@ -2689,10 +2685,18 @@ bool
2689file_accessible_directory_p (Lisp_Object file) 2685file_accessible_directory_p (Lisp_Object file)
2690{ 2686{
2691#ifdef DOS_NT 2687#ifdef DOS_NT
2692 /* There's no need to test whether FILE is searchable, as the 2688# ifdef WINDOWSNT
2693 searchable/executable bit is invented on DOS_NT platforms. */ 2689 /* We need a special-purpose test because (a) NTFS security data is
2690 not reflected in Posix-style mode bits, and (b) the trick with
2691 accessing "DIR/.", used below on Posix hosts, doesn't work on
2692 Windows, because "DIR/." is normalized to just "DIR" before
2693 hitting the disk. */
2694 return (SBYTES (file) == 0
2695 || w32_accessible_directory_p (SSDATA (file), SBYTES (file)));
2696# else /* MSDOS */
2694 return file_directory_p (SSDATA (file)); 2697 return file_directory_p (SSDATA (file));
2695#else 2698# endif /* MSDOS */
2699#else /* !DOS_NT */
2696 /* On POSIXish platforms, use just one system call; this avoids a 2700 /* On POSIXish platforms, use just one system call; this avoids a
2697 race and is typically faster. */ 2701 race and is typically faster. */
2698 const char *data = SSDATA (file); 2702 const char *data = SSDATA (file);
@@ -2725,7 +2729,7 @@ file_accessible_directory_p (Lisp_Object file)
2725 SAFE_FREE (); 2729 SAFE_FREE ();
2726 errno = saved_errno; 2730 errno = saved_errno;
2727 return ok; 2731 return ok;
2728#endif 2732#endif /* !DOS_NT */
2729} 2733}
2730 2734
2731DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0, 2735DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0,