&stat(4)&stat - Retrieve a file statistic
&stat <stat> <filename>
&stat returns the specified <stat> on the given <filename>. Valid <stat> values are:-
a
d
i
1
F File is an ftp URL file (see note). H File is a http URL link (see note). L File is a local file (may be prefixed with 'file:'). T File is a tfs file (tfs://...).
2
D File is a directory. H File is a http URL link (no further information is known). L File is a symbolic link (UNIX). N File is an untouchable system file. R File is a regular file. X File does not exist.
Note the information returned here is different to the 't' flag below as the type of an ftp file is evaluated, i.e. D, R or X will be returned.
3
D File is a directory. N File is an untouchable system file. R File is a regular file. X File does not exist.
4
5 and 6
7
m
r
s
t
X File does not exist. R File is a regular file. D File is a directory. H File is a http URL link (see note). F File is an ftp URL file (see note). N File is an untouchable system file.
w
x
The URL type is determined from the start of the file name, e.g. http://..., and its existence is never verified if a http, nor for an ftp URL except for an i stat.
The following URL types are supported depending on the build of MicroEmacs:
file: Local file. ftp:// Standard ftp URL (default port 21). ftpe:// Explicit secure ftp (default port 21). ftps:// Implicit secure ftp (default port 990). http:// Standard http URL (default port 80). https:// Secure http URL (default port 443). tfs:// Tacked-on file system URL.
The following example is a macro which, given a file name, uses &stat to check that file file is regular:
define-macro test-file !force set-variable #l0 @1 !if ¬ $status set-variable #l0 @ml04 "File name" !endif !if ¬ &equ &stat "t" #l4 1 ml-write &spr "[%s is not a regular file]" #l0 !abort !endif !emacro test-file "foobar"
The macro can be passed a file name and aborts if the file is not regular, there by returning the state.
The follow example checks that a file is not empty, this is used by mail-check to test for any incoming mail.
!if &gre &stat "s" %incoming-mail-box ml-write "[You have new mail]" !endif
(c) Copyright JASSPA 2025
Last Modified: 2023/02/21
Generated On: 2025/09/29