ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
home.m
Go to the documentation of this file.
1%> \brief
2%> Return a MATLAB string containing the
3%> absolute path to the system home directory.<br>
4%>
5%> \return
6%> ``path`` : A MATLAB string containing the
7%> absolute path to the system home directory.<br>
8%>
9%> \interface{home}
10%> \code{.m}
11%>
12%> path = pm.sys.path.home()
13%>
14%> \endcode
15%>
16%> \example{home}
17%> \include{lineno} example/sys/path/home/main.m
18%> \output{home}
19%> \include{lineno} example/sys/path/home/main.out.m
20%>
21%> \final{home}
22%>
23%> \author
24%> \JoshuaOsborne, May 21 2024, 5:25 AM, University of Texas at Arlington<br>
25%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
26%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
27function path = home()
28 persistent homePathPersistent
29 %freshRequested = false;
30 %if nargin==0
31 % if isempty(homePathPersistent); freshRequested = true; end
32 %elseif nargin==1 && ( strcmpi(string(varargin{1}),"fresh") || strcmpi(string(varargin{1}),"new") || strcmpi(string(varargin{1}),"reset") )
33 % freshRequested = true;
34 %else
35 % error( "home() takes at most one argument of the following values: ""new"", ""fresh"", ""reset"", all with the same meaning." );
36 %end
37 %if freshRequested
38 if ispc
39 [failed, homePathPersistent] = system("echo %HOMEPATH%");
40 if failed
41 error ( newline ...
42 + "Failed to capture the path to the home directory of the Windows system." + newline ...
43 + "This is highlt unusual and likely a low-level MATLAB problem." + newline ...
44 + newline ...
45 );
46 else
47 homePathPersistent = strtrim(homePathPersistent);
48 end
49 else
50 homePathPersistent = strtrim(pm.sys.path.abs("~"));
51 end
52 %end
53 path = string(homePathPersistent);
54end
function home()
Return a MATLAB string containing the absolute path to the system home directory.