[Top][All Lists]

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

bug#15130: 24.3.50; emacs-24.3.1 on Windows; possible `file-directory-p'

From: Eli Zaretskii
Subject: bug#15130: 24.3.50; emacs-24.3.1 on Windows; possible `file-directory-p' bug.
Date: Mon, 19 Aug 2013 18:43:25 +0300

> From: Thierry Volpiatto <address@hidden>
> Date: Mon, 19 Aug 2013 10:47:24 +0200
> On windows `file-directory-p' returns t on a path with a space added at
> end.
> ;; windows-nt
> (file-directory-p "c:/Program 
> Files/emacs-24.3-bin-i386/emacs-24.3/site-lisp/")
> t
> (file-directory-p "c:/Program Files/emacs-24.3-bin-i386/emacs-24.3/site-lisp/ 
> ")
> t
> ;; gnu/linux
> (file-directory-p "~/.emacs.d/")
> t
> (file-directory-p "~/.emacs.d/ ")
> nil
> Is it wanted?

It's wanted only if you really have a directory named " " under 
'c:/Program Files/emacs-24.3-bin-i386/emacs-24.3/site-lisp/' ;-)

Seriously, though: this is not Emacs's fault.  There's no code in
Emacs that removes that space from the name; we simply hand the
(expanded) file name to the Windows API that returns file attributes,
and if the returned attributes say it's a directory, we return t.

More generally, all Win32 APIs ignore trailing whitespace in file
names.  OTOH, it _is_ possible to create file names such as "/foo/ "
on Windows (by using a file-name syntax that bypasses the Win32
file-name normalization layer), so rejecting file names such as the
one you show is not an option.  On the third hand, converting every
file name to that syntax internally, so that we bypass the
normalization, is a large job, whose risks are unknown, at least to
me, and whose gains are quite small, since use cases where you trip
upon such problems are very rare (can you tell what was your use case,

So I think we will have to continue living with this idiosyncrasy of
Windows filesystems.

reply via email to

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