Function: file-accessible-directory-p

file-accessible-directory-p is a function defined in fileio.c.

Signature

(file-accessible-directory-p FILENAME)

Documentation

Return t if FILENAME names a directory you can open.

This means that FILENAME must specify the name of a directory, and the directory must allow you to open files in it. If this isn't the case, return nil.

FILENAME can either be a directory name (eg. "/tmp/foo/") or the file name of a file which is a directory (eg. "/tmp/foo", without the final slash).

In order to use a directory as a buffer's current directory, this predicate must return true.

Other relevant functions are documented in the file group.

View in manual

Shortdoc

;; file
(file-accessible-directory-p "/tmp")
    e.g. => t

Source Code

// Defined in /usr/src/emacs/src/fileio.c
{
  Lisp_Object absname;
  Lisp_Object handler;

  CHECK_STRING (filename);
  absname = Fexpand_file_name (filename, Qnil);

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  handler = Ffind_file_name_handler (absname, Qfile_accessible_directory_p);
  if (!NILP (handler))
    {
      Lisp_Object r = call2 (handler, Qfile_accessible_directory_p, absname);

      /* Set errno in case the handler failed.  EACCES might be a lie
	 (e.g., the directory might not exist, or be a regular file),
	 but at least it does TRT in the "usual" case of an existing
	 directory that is not accessible by the current user, and
	 avoids reporting "Success" for a failed operation.  Perhaps
	 someday we can fix this in a better way, by improving
	 file-accessible-directory-p's API; see Bug#25419.  */
      if (!EQ (r, Qt))
	errno = EACCES;

      return r;
    }

  Lisp_Object encoded_absname = ENCODE_FILE (absname);
  return file_accessible_directory_p (encoded_absname) ? Qt : Qnil;
}