Mercurial > octave-nkf
comparison libinterp/corefcn/sysdep.cc @ 20051:47d420d769ba
* sysdep.cc (Fget_home_directory): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 02 Apr 2015 13:08:34 -0400 |
parents | 19755f4fc851 |
children | cf9b94a89620 |
comparison
equal
deleted
inserted
replaced
20050:519eb032ac35 | 20051:47d420d769ba |
---|---|
1001 return retval; | 1001 return retval; |
1002 } | 1002 } |
1003 | 1003 |
1004 /* | 1004 /* |
1005 %!test | 1005 %!test |
1006 %! if (isempty (getenv ("HOME"))) | 1006 %! home = get_home_directory (); |
1007 %! setenv ("HOME", "foobar"); | 1007 %! assert (tilde_expand ("~/foobar"), fullfile (home, "/foobar")); |
1008 %! endif | |
1009 %! home = getenv ("HOME"); | |
1010 %! assert (tilde_expand ("~/foobar"), strcat (home, "/foobar")); | |
1011 %! assert (tilde_expand ("/foo/bar"), "/foo/bar"); | 1008 %! assert (tilde_expand ("/foo/bar"), "/foo/bar"); |
1012 %! assert (tilde_expand ("foo/bar"), "foo/bar"); | 1009 %! assert (tilde_expand ("foo/bar"), "foo/bar"); |
1013 */ | 1010 */ |
1011 | |
1012 DEFUN (get_home_directory, , , | |
1013 "-*- texinfo -*-\n\ | |
1014 @deftypefn {Built-in Function} {} get_home_directory ()\n\ | |
1015 Return the current home directory. On most systems, this is equivalent\n\ | |
1016 to @code{getenv (\"HOME\")}. On Windows systems, if @env{HOME} is not\n\ | |
1017 set in the environment, it is equivalent to\n\ | |
1018 @code{fullfile (getenv (\"HOMEDRIVE\"), getenv (\"HOMEPATH\"))}\n\ | |
1019 @seealso{getenv}\n\ | |
1020 @end deftypefn") | |
1021 { | |
1022 return octave_value (octave_env::get_home_directory ()); | |
1023 } | |
1014 | 1024 |
1015 // This function really belongs in display.cc, but including defun.h in | 1025 // This function really belongs in display.cc, but including defun.h in |
1016 // that file results in conflicts with symbols from headers that are | 1026 // that file results in conflicts with symbols from headers that are |
1017 // needed for X11 and Carbon functions. | 1027 // needed for X11 and Carbon functions. |
1018 | 1028 |