Function: directory-file-name
directory-file-name is a function defined in fileio.c.
Signature
(directory-file-name DIRECTORY)
Documentation
Returns the file name of the directory named DIRECTORY.
This is the name of the file that holds the data for the directory DIRECTORY. This operation exists because a directory is also a file, but its name as a directory is different from its name as a file. In Unix-syntax, this function just removes the final slash.
Other relevant functions are documented in the file-name group.
Probably introduced at or before Emacs version 18.
Shortdoc
;; file-name
(directory-file-name "/tmp/foo/")
=> "/tmp/foo"
Source Code
// Defined in /usr/src/emacs/src/fileio.c
{
char *buf;
ptrdiff_t length;
Lisp_Object handler, val;
USE_SAFE_ALLOCA;
CHECK_STRING (directory);
/* If the file name has special constructs in it,
call the corresponding file name handler. */
handler = Ffind_file_name_handler (directory, Qdirectory_file_name);
if (!NILP (handler))
{
Lisp_Object handled_name = calln (handler, Qdirectory_file_name,
directory);
if (STRINGP (handled_name))
return handled_name;
error ("Invalid handler in `file-name-handler-alist'");
}
#ifdef WINDOWSNT
if (!NILP (Vw32_downcase_file_names))
directory = Fdowncase (directory);
#endif
buf = SAFE_ALLOCA (SBYTES (directory) + 1);
length = directory_file_name (buf, SSDATA (directory), SBYTES (directory),
STRING_MULTIBYTE (directory));
val = make_specified_string (buf, -1, length, STRING_MULTIBYTE (directory));
SAFE_FREE ();
return val;
}