# HG changeset patch # User John W. Eaton # Date 1427994514 14400 # Node ID 47d420d769ba819f2ea0a63eb6860390b1988d77 # Parent 519eb032ac35e433c6415827715bbf40e34d84f7 * sysdep.cc (Fget_home_directory): New function. diff -r 519eb032ac35 -r 47d420d769ba libinterp/corefcn/sysdep.cc --- a/libinterp/corefcn/sysdep.cc Thu Apr 02 13:08:56 2015 -0400 +++ b/libinterp/corefcn/sysdep.cc Thu Apr 02 13:08:34 2015 -0400 @@ -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.