File paths (search in selected directories)
paths = CL_path(names [[, directories, opt, err, hid, maxdepth, smode, ftype]])
Looks for files in directories and returns their paths.
names can be a file (or directory) name or a string containing wildcards ("*").
If directories is omitted or is a white space (""): %CL_PATH is searched if it is defined, otherwise, an error is raised.
The argument opt specifies the possible search options:
opt = "first" (or "std"): Returns the path of the first file found.
opt = "all": Returns the paths of all the files found.
Default is "first".
The argument smode specifies the type of search:
smode = "df": depth-first: look for names in directory1, directory1/subdir1, directory1/subdir1/subdir1 ..., directory1/subdir1/subdir2, ... directory1/subdir2, ..., directory2, ...
smode = "bf": breadth-first: look for names in directory1, directory2 ..., then in all subdirectories of directory1, directory2 ..., then in all subdirectories of subdirectories of directory1, directory2..., etc...
Default is "bf".
The option ftype specifies the type of file to find:
ftype = "f" : Files only.
ftype = "d" : Directories only.
ftype = "any" : Any type.
Default is "any".
If no file is found, the returned value is []. An error is raised if err == %t and opt == "first").
If hid is %t, hidden sub-directories (whose name begin with ".") are searched, otherwise they're not. Only (sub) directories not explicitly mentioned in the calling sequence are concerned.
The maximum depth for the search can be specified by maxdepth. It is 50 by default. 0 means that files are looked-for in the specified directories only.
If last part of a directory name (in "directories") is "*", the name of the directory is replaced by the list of all its sub-directories.
(string) Name(s) of file(s) to be looked for (may contain wildcards). (1xN)
(string, optional) Directories to be searched. Default is "", meaning %CL_PATH if it exists (1xP)
(string, optional) Search option: "first" (or "std") or "all". Default is "first" (1x1)
(boolean, optional) %t is an error is raised if no file is found. Default is %t except if opt == "all" (1x1)
(boolean, optional) %t if hidden sub-directories are included in the search. Default is %f (1x1)
(integer >=0, optional) Maximum depth for the search. Default is 50 (1x1)
(string, optional) Search smode: "df" or "bf". Default is "bf" (1x1)
(string, optional) Type of files: "d" or "f" or "any". Default is "any" (1x1)
(string) File path(s) or [] if no file is found (1xQ)
CNES - DCT/SB
// Looks for "readme.txt" in CL_home() - returns the first file found CL_path("readme.txt", CL_home()) // Returns all "*.scd" file in "data" (deep search) CL_path("*.scd", fullfile(CL_home(), "data"), "all") | ![]() | ![]() |