Check for the existence of name as a variable, function, file, directory, or class.
The return code c is one of
name is a variable.
name is an absolute filename, an ordinary file in Octave’s
path
, or (after appending ‘.m’) a function file in Octave’s
path
.
name is a ‘.oct’ or ‘.mex’ file in Octave’s path
.
name is a built-in function.
name is a directory.
name is a function not associated with a file (entered on the command line).
name does not exist.
If the optional argument type is supplied, check only for symbols of the specified type. Valid types are
"var"
Check only for variables.
"builtin"
Check only for built-in functions.
"dir"
Check only for directories.
"file"
Check only for files and directories.
"class"
Check only for classes. (Note: This option is accepted, but not currently implemented)
If no type is given, and there are multiple possible matches for name,
exist
will return a code according to the following priority list:
variable, built-in function, oct-file, directory, file, class.
exist
returns 2 if a regular file called name is present in
Octave’s search path. If you want information about other types of files
not on the search path you should use some combination of the functions
file_in_path
and stat
instead.
Programming Note: If name is implemented by a buggy .oct/.mex file, calling exist may cause Octave to crash. To maintain high performance, Octave trusts .oct/.mex files instead of sandboxing them.
See also: file_in_loadpath, file_in_path, dir_in_loadpath, stat.
Package: octave