ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
webglob.m
Go to the documentation of this file.
1%> \brief
2%> Return a scalar MATLAB string or vector of MATLAB strings
3%> containing the fully-resolved paths matching the input pattern.<br>
4%>
5%> \details
6%> This function is very similar to [pm.sys.path.glob](@ref glob).<br>
7%> However, unlike [pm.sys.path.glob](@ref glob), if the input
8%> pattern matches a World Wide Web link, it will also
9%> download the file to a temporary path on the system
10%> and the temporary download path as the output.<br>
11%>
12%> \param[in] pattern : The input scalar MATLAB string containing either:<br>
13%> <ol>
14%> <li> the pattern to search for paths on the current system.<br>
15%> Wildcards may be used for basenames and for the directory parts.<br>
16%> If pattern contains directory parts, then these will
17%> be included in the output ``pathList``.<br>
18%> Following wildcards can be used:<br>
19%> <ol>
20%> <li> ``*`` match zero or more characters.<br>
21%> <li> ``?`` match any single character.<br>
22%> <li> ``[ab12]`` match one of the specified characters.<br>
23%> <li> ``[^ab12]`` match none of the specified characters.<br>
24%> <li> ``[a-z]`` match one character in range of characters.<br>
25%> <li> ``{a,b,c}`` matches any one of strings ``a``, ``b``, or ``c``.<br>
26%> <li> All above wildcards do not match a file separator.<br>
27%> <li> ``**`` match zero or more characters including file separators.<br>
28%> This can be used to match zero or more directory parts
29%> and will recursively list matching names.<br>
30%> </ol>
31%> <li> the weblink to download and save locally on the system temporary folder.<br>
32%> </ol>
33%>
34%> \param[in] anycase : The input scalar MATLAB logical.<br>
35%> If ``true``, the search will be case-sensitive.<br>
36%> If ``false``, the search will be case-insensitive.<br>
37%> On Windows, ``anycase`` is always reset to ``true`` even if user-specified.<br>
38%> (**optional**. default = ``false`` on Unix and ``true`` on Windows.)
39%>
40%> \return
41%> ``pathList`` : The output MATLAB cell array of strings containing the files
42%> or directories that match the path specified by string ``pattern``.<br>
43%> ``isdirList`` : The output MATLAB cell array of the same size as ``pathList``,
44%> each element of which is a MATLAB logical value that is ``true`` if
45%> and only if the corresponding element of ``pathList`` is a directory.<br>
46%>
47%> \warning
48%> Symbolic linked directories or junctions may cause an infinite loop when using the ``**``.<br>
49%>
50%> \interface{webglob}
51%> \code{.m}
52%>
53%> [pathList, isdirList] = pm.sys.path.webglob(pattern)
54%> [pathList, isdirList] = pm.sys.path.webglob(pattern, anycase)
55%>
56%> \endcode
57%>
58%> \example{webglob}
59%> \include{lineno} example/sys/path/webglob/main.m
60%> \output{webglob}
61%> \include{lineno} example/sys/path/webglob/main.out.m
62%>
63%> \final{webglob}
64%>
65%> \author
66%> \JoshuaOsborne, May 21 2024, 5:10 AM, University of Texas at Arlington<br>
67%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
68%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
69function [pathList, isdirList] = webglob(pattern, anycase)
70 if nargin < 2
71 anycase = [];
72 end
73 [pathList, isdirList] = pm.sys.path.glob(pattern, anycase);
74 if isempty(pathList)
75 %%%%
76 %%%% check if the input path is a weblink.
77 %%%%
78 if pm.web.isurl(pattern)
79 %%%%
80 %%%% Extract the weblink file name.
81 %%%%
82 parts = split(pattern, "/");
83 if parts(end) ~= ""
84 pathtmp = fullfile(tempdir(), parts(end));
85 else
86 pathtmp = tempname();
87 end
88 pathList = [string(websave(pathtmp, pattern))];
89 end
90 end
91end
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 glob(in pattern, in anycase)
Find all files and directory names matching the input pattern by expanding wildcards.
function webglob(in pattern, in anycase)
Return a scalar MATLAB string or vector of MATLAB strings containing the fully-resolved paths matchin...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...