Function: file-regular-p
file-regular-p is a function defined in fileio.c.
Signature
(file-regular-p FILENAME)
Documentation
Return t if FILENAME names a regular file.
This is the sort of file that holds an ordinary stream of data bytes.
Return nil if FILENAME does not exist or is not a regular file,
or there was trouble determining whether FILENAME is a regular file.
Symbolic links to regular files count as regular files.
See file-symlink-p to distinguish symlinks.
Other relevant functions are documented in the file group.
Probably introduced at or before Emacs version 19.29.
Shortdoc
;; file
(file-regular-p "/tmp/foo")
e.g. => t
Aliases
Source Code
// Defined in /usr/src/emacs/src/fileio.c
{
struct stat st;
Lisp_Object absname = expand_and_dir_to_file (filename);
/* If the file name has special constructs in it,
call the corresponding file name handler. */
Lisp_Object handler = Ffind_file_name_handler (absname, Qfile_regular_p);
if (!NILP (handler))
return call2 (handler, Qfile_regular_p, absname);
#ifdef WINDOWSNT
/* Tell stat to use expensive method to get accurate info. */
Lisp_Object true_attributes = Vw32_get_true_file_attributes;
Vw32_get_true_file_attributes = Qt;
#endif
int stat_result = emacs_fstatat (AT_FDCWD, SSDATA (absname), &st, 0);
#ifdef WINDOWSNT
Vw32_get_true_file_attributes = true_attributes;
#endif
return stat_result == 0 && S_ISREG (st.st_mode) ? Qt : Qnil;
}