Mercurial > hg > octave-nkf
diff libinterp/corefcn/sysdep.cc @ 20226: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 |
line wrap: on
line diff
--- a/libinterp/corefcn/sysdep.cc +++ b/libinterp/corefcn/sysdep.cc @@ -1003,15 +1003,25 @@ /* %!test -%! if (isempty (getenv ("HOME"))) -%! setenv ("HOME", "foobar"); -%! endif -%! home = getenv ("HOME"); -%! assert (tilde_expand ("~/foobar"), strcat (home, "/foobar")); +%! home = get_home_directory (); +%! assert (tilde_expand ("~/foobar"), fullfile (home, "/foobar")); %! assert (tilde_expand ("/foo/bar"), "/foo/bar"); %! assert (tilde_expand ("foo/bar"), "foo/bar"); */ +DEFUN (get_home_directory, , , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} get_home_directory ()\n\ +Return the current home directory. On most systems, this is equivalent\n\ +to @code{getenv (\"HOME\")}. On Windows systems, if @env{HOME} is not\n\ +set in the environment, it is equivalent to\n\ +@code{fullfile (getenv (\"HOMEDRIVE\"), getenv (\"HOMEPATH\"))}\n\ +@seealso{getenv}\n\ +@end deftypefn") +{ + return octave_value (octave_env::get_home_directory ()); +} + // This function really belongs in display.cc, but including defun.h in // that file results in conflicts with symbols from headers that are // needed for X11 and Carbon functions.