Subject: bug#78306: closed (Re: bug#78306: [PATCH] Skip the non-exists path when loading a file on Windows)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 24 May 2025 13:09:03 +0000

Your bug report

#78306: [PATCH] Skip the non-exists path when loading a file on Windows

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
78306: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78306
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#78306: [PATCH] Skip the non-exists path when loading a file on Windows
From: Eli Zaretskii <[email-masked]>
To: Lin Sun <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked]
Date: Sat, 24 May 2025 16:08:25 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Sat, 24 May 2025 05:25:27 -0700
> From: Lin Sun <[email-masked]>
> Cc: [email-masked], [email-masked],
>  [email-masked]
> 
> On May 24, 2025 1:46 AM, Eli Zaretskii <[email-masked]> wrote:
> 
>  Any progress with this?  Should we close this bug? 
> 
> One non-existing dir will be used during boot startup, no harmful there; and on my local, several non-existing
> dirs were added into load path by an external package management, I created a PR for it.
> 
> Please feel free to close this ticket, thank you.

Thanks, done.

Subject: [PATCH] Skip the non-exists path when loading a file on Windows
From: Lin Sun <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Thu, 8 May 2025 00:19:24 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Emacs will searching file with a suffix even the dir is not exists.
For example, (add-to-list 'load-path "/path-not-exists"), then (require 'debug) will lead searching the debug.dll/debug.elc/debug.el under the "/path-not-exists" on windows.

This patch will distinguish the non-exists-dir to skip the unnecessary file operations.
From bb8b2c6b95eb74d224910fb09b8e682cc006c066 Mon Sep 17 00:00:00 2001
From: Lin Sun <[email-masked]>
Date: Wed, 7 May 2025 06:30:02 -0700
Subject: [PATCH] Skip the non-exists path when loading a file on Windows

* src/lread.c (faccessat): Assign errno=ENOTDIR for dir not exists
* src/w32.c (openp): Skip current path if it does not exists
---
 src/lread.c | 5 ++++-
 src/w32.c   | 6 ++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/lread.c b/src/lread.c
index 95c9e71..5d044c4 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2152,8 +2152,11 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
                     it.  Only open the file when we are sure that it
                     exists.  */
 #ifdef WINDOWSNT
-                if (sys_faccessat (AT_FDCWD, pfn, R_OK, AT_EACCESS))
+                if (sys_faccessat (AT_FDCWD, pfn, R_OK, AT_EACCESS)) {
+		  if (errno == ENOTDIR) /* dir not exists, continue on next path */
+		    break;
                   fd = -1;
+		}
                 else
 #endif
 		  {
diff --git a/src/w32.c b/src/w32.c
index d7bf173..0fd4ea4 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4185,12 +4185,14 @@ faccessat (int dirfd, const char * path, int mode, int flags)
 	    }
 	  /* FALLTHROUGH */
 	  FALLTHROUGH;
-	case ERROR_FILE_NOT_FOUND:
 	case ERROR_PATH_NOT_FOUND:
 	case ERROR_INVALID_DRIVE:
-	case ERROR_NOT_READY:
 	case ERROR_BAD_NETPATH:
+	  errno = ENOTDIR;
+	  break;
 	case ERROR_BAD_NET_NAME:
+	case ERROR_FILE_NOT_FOUND:
+	case ERROR_NOT_READY:
 	  errno = ENOENT;
 	  break;
 	default:
-- 
2.49.0