emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master e634dac: Fix directory accessibility tests for w32


From: Eli Zaretskii
Subject: [Emacs-diffs] master e634dac: Fix directory accessibility tests for w32 network volumes
Date: Mon, 31 Aug 2015 14:58:05 +0000

branch: master
commit e634dacce7ee3bcb4d8aba9e6ad125b6b875c179
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix directory accessibility tests for w32 network volumes
    
    * src/w32.c (faccessat): Don't fail with network volumes without a
    share.
    (w32_accessible_directory_p): Handle network volumes without a
    share.
---
 src/w32.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/w32.c b/src/w32.c
index dea8431..cc55507 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3826,7 +3826,7 @@ faccessat (int dirfd, const char * path, int mode, int 
flags)
                  errno = EACCES;
                  return -1;
                }
-             break;
+             goto check_attrs;
            }
          /* FALLTHROUGH */
        case ERROR_FILE_NOT_FOUND:
@@ -3839,6 +3839,8 @@ faccessat (int dirfd, const char * path, int mode, int 
flags)
        }
       return -1;
     }
+
+ check_attrs:
   if ((mode & X_OK) != 0
       && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0))
     {
@@ -3871,6 +3873,23 @@ w32_accessible_directory_p (const char *dirname, 
ptrdiff_t dirlen)
   bool last_slash = dirlen > 0 && IS_DIRECTORY_SEP (dirname[dirlen - 1]);
   HANDLE dh;
 
+  /* Network volumes need a different reading method.  */
+  if (is_unc_volume (dirname))
+    {
+      void *read_result = NULL;
+      wchar_t fnw[MAX_PATH];
+      char fna[MAX_PATH];
+
+      dh = open_unc_volume (dirname);
+      if (dh != INVALID_HANDLE_VALUE)
+       {
+         read_result = read_unc_volume (dh, fnw, fna, MAX_PATH);
+         close_unc_volume (dh);
+       }
+      /* Treat empty volumes as accessible.  */
+      return read_result != NULL || GetLastError () == ERROR_NO_MORE_ITEMS;
+    }
+
   /* Note: map_w32_filename makes sure DIRNAME is not longer than
      MAX_UTF8_PATH.  */
   strcpy (pattern, map_w32_filename (dirname, NULL));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]