emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 9664def: Signal a file-error from directory-files


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-24 9664def: Signal a file-error from directory-files on MS-Windows (Bug#19701)
Date: Tue, 27 Jan 2015 19:04:12 +0000

branch: emacs-24
commit 9664defd262252faf037c5fe1ea095f1cc4b308b
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Signal a file-error from directory-files on MS-Windows  (Bug#19701)
    
     src/dired.c (directory_files_internal) [WINDOWSNT]: If readdir
     returns NULL and errno is ENOTDIR, behave as if opendir failed to
     open the directory.
     src/w32.c (sys_readdir): If FindFirstFile fails because the
     directory doesn't exist, set errno to ENOTDIR.
---
 src/ChangeLog |    9 +++++++++
 src/dired.c   |   13 +++++++++++++
 src/w32.c     |   17 ++++++++++++++++-
 3 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 9cf5eb5..a33e834 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2015-01-27  Eli Zaretskii  <address@hidden>
+
+       * dired.c (directory_files_internal) [WINDOWSNT]: If readdir
+       returns NULL and errno is ENOTDIR, behave as if opendir failed to
+       open the directory.  (Bug#19701)
+
+       * w32.c (sys_readdir): If FindFirstFile fails because the
+       directory doesn't exist, set errno to ENOTDIR.
+
 2015-01-24  Jan Djärv  <address@hidden>
 
        * nsterm.m (drawRect:): Add block/unblock_input (Bug#19660).
diff --git a/src/dired.c b/src/dired.c
index 5d7977b..f6c47a7 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -247,6 +247,19 @@ directory_files_internal (Lisp_Object directory, 
Lisp_Object full,
              QUIT;
              continue;
            }
+#ifdef WINDOWSNT
+         /* The MS-Windows implementation of 'opendir' doesn't
+            actually open a directory until the first call to
+            'readdir'.  If 'readdir' fails to open the directory, it
+            sets errno to ENOTDIR; we convert it here to ENOENT so
+            that the error message is similar to what happens on
+            Posix hosts in such cases.  */
+         if (errno == ENOTDIR)
+           {
+             errno = ENOENT;
+             report_file_error ("Opening directory", directory);
+           }
+#endif
          break;
        }
 
diff --git a/src/w32.c b/src/w32.c
index 09902a2..aedf649 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3432,7 +3432,22 @@ sys_readdir (DIR *dirp)
        }
 
       if (dir_find_handle == INVALID_HANDLE_VALUE)
-       return NULL;
+       {
+         switch (GetLastError ())
+           {
+           case ERROR_PATH_NOT_FOUND:
+           case ERROR_ACCESS_DENIED:
+           case ERROR_INVALID_DRIVE:
+           case ERROR_BAD_NETPATH:
+             /* This special value will be noticed by
+                directory_files_internal, which see.  */
+             errno = ENOTDIR;
+             break;
+           default:
+             break;
+           }
+         return NULL;
+       }
     }
   else if (w32_unicode_filenames)
     {



reply via email to

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