@end example
@end defun
-@defun directory-name-p filename
-This function returns non-@code{nil} if @var{filename} ends with a
-forward slash (@samp{/}) character.
-@end defun
-
@node Directory Names
@subsection Directory Names
@cindex directory name
@end example
@end defun
+@defun directory-name-p filename
+This function returns non-@code{nil} if @var{filename} ends with a
+directory separator character. This is the forward slash @samp{/} on
+Unix and GNU systems; MS-Windows and MS-DOS recognize both the forward
+slash and the backslash @samp{\} as directory separators.
+@end defun
+
@defun directory-file-name dirname
This function returns a string representing @var{dirname} in a form
that the operating system will interpret as the name of a file (a
hiding character but the default `.' can be used by let-binding the
variable `read-hide-char'.
-** The new function `directory-name-p' can be used to check whether a file
-name (as returned from, for instance, `file-name-all-completions' is
-a directory file name. It returns non-nil if the last character in
-the name is a forward slash.
-
** The function `font-info' now returns more details about a font.
In particular, it now returns the average width of the font's
characters, which can be used for geometry-related calculations.
** New function `set-binary-mode' allows to switch a standard stream
of the Emacs process to binary I/O mode.
++++
+** The new function `directory-name-p' can be used to check whether a file
+name (as returned from, for instance, `file-name-all-completions') is
+a directory file name. It returns non-nil if the last character in
+the name is a directory separator character (forward slash on GNU and
+Unix systems, forward- or backslash on MS-Windows and MS-DOS).
+
** ASCII approximations to curved quotes are put in standard-display-table
if the terminal cannot display curved quotes.
(error "No such directory found via CDPATH environment variable"))))
(defsubst directory-name-p (name)
- "Return non-nil if NAME ends with a slash character."
- (and (> (length name) 0)
- (char-equal (aref name (1- (length name))) ?/)))
+ "Return non-nil if NAME ends with a directory separator character."
+ (let ((len (length name))
+ (lastc ?.))
+ (if (> len 0)
+ (setq lastc (aref name (1- len))))
+ (or (= lastc ?/)
+ (and (memq system-type '(windows-nt ms-dos))
+ (= lastc ?\\)))))
(defun directory-files-recursively (dir regexp &optional include-directories)
"Return list of all files under DIR that have file names matching REGEXP.