ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
list.m
Go to the documentation of this file.
1%> \brief
2%> Return a cell vector of MATLAB string values each of which
3%> corresponds to one **non-default** file or folder path
4%> in the specified input directory path.<br>
5%>
6%> \note
7%> The primary use of this function is to create a list of items
8%> in a given folder while excluding the default system items
9%> which includes the current and parent directories.<br>
10%>
11%> \param[in] path : The input scalar MATLAB string or character containing the path to an
12%> existing directory whose file and folder contents should be listed,
13%> excluding the default ``"."`` and ``".."`` system paths.<br>
14%> (**optional**, default = ``"."``)
15%>
16%> \return
17%> ``namelist`` : A MATLAB cell vector, each element of which corresponds to an existing
18%> non-default file or folder in the specified input directory path.<br>
19%> If the input path contains a base directory name, the name will
20%> be prefixed to each item in the output ``namelist``.<br>
21%> If the input `path` is not a directory or is empty,
22%> the output `namelist` will be empty.<br>
23%>
24%> \interface{list}
25%> \code{.m}
26%>
27%> namelist = pm.sys.path.list()
28%> namelist = pm.sys.path.list(path)
29%>
30%> \endcode
31%>
32%> \example{list}
33%> \include{lineno} example/sys/path/list/main.m
34%> \output{list}
35%> \include{lineno} example/sys/path/list/main.out.m
36%>
37%> \final{list}
38%>
39%> \author
40%> \JoshuaOsborne, May 21 2024, 5:26 AM, University of Texas at Arlington<br>
41%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
42%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
43function namelist = list(path)
44 if nargin < 1
45 path = ".";
46 end
47 namelist = [];
48 if isfolder(path)
49 [dirname, ~, ~] = fileparts(path);
50 fileSpecList = dir(path);
51 namelistRaw = string({fileSpecList.name});
52 namelistLen = length(namelistRaw);
53 cleanListLen = namelistLen - (any(strcmp(namelistRaw, ".")) + any(strcmp(namelistRaw, "..")));
54 if cleanListLen == namelistLen
55 namelist = fullfile(dirname, namelistRaw);
56 else
57 namelist = strings([cleanListLen, 1]);
58 counter = 0;
59 for i = 1 : namelistLen
60 if ~(strcmp(namelistRaw(i), ".") || strcmp(namelistRaw(i), ".."))
61 counter = counter + 1;
62 namelist(counter) = fullfile(dirname, namelistRaw(i));
63 end
64 end
65 end
66 end
67end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...