changeset 21906:e0952881e051

prefdir: Turn into a public function, make Matlab compatible (bug #48221) * prefdir.m: Move from private subdir. Accept any argument to create a nonexistent prefdir. * scripts/prefs/module.mk (scripts_prefs_FCN_FILES): Add prefdir.m to the list. (scripts_prefs_PRIVATE_FCN_FILES): Remove prefdir.m from the list.
author Mike Miller <mtmiller@octave.org>
date Wed, 15 Jun 2016 09:02:17 -0700
parents 0c3f7fec9c1e
children 98f5dd2ff29a
files scripts/prefs/module.mk scripts/prefs/prefdir.m scripts/prefs/private/prefdir.m
diffstat 3 files changed, 58 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/prefs/module.mk	Wed Jun 15 08:56:43 2016 -0700
+++ b/scripts/prefs/module.mk	Wed Jun 15 09:02:17 2016 -0700
@@ -4,7 +4,6 @@
 
 scripts_prefs_PRIVATE_FCN_FILES = \
   scripts/prefs/private/loadprefs.m \
-  scripts/prefs/private/prefdir.m \
   scripts/prefs/private/prefsfile.m \
   scripts/prefs/private/saveprefs.m
 
@@ -12,6 +11,7 @@
   scripts/prefs/addpref.m \
   scripts/prefs/getpref.m \
   scripts/prefs/ispref.m \
+  scripts/prefs/prefdir.m \
   scripts/prefs/preferences.m \
   scripts/prefs/rmpref.m \
   scripts/prefs/setpref.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/prefs/prefdir.m	Wed Jun 15 09:02:17 2016 -0700
@@ -0,0 +1,57 @@
+## Copyright (C) 2013-2015 John Donoghue
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {} {} prefdir
+## @deftypefnx {} {} prefdir (1)
+## @deftypefnx {} {@var{dir} =} prefdir
+## Return the directory that holds the preferences for Octave.
+##
+## Examples:
+##
+## Display the preferences directory
+##
+## @example
+## prefdir
+## @end example
+##
+## Change to the preferences folder
+##
+## @example
+## cd (prefdir)
+## @end example
+##
+## If called with an argument, the preferences directory is created if it
+## doesn't already exist.
+## @seealso{getpref, setpref, addpref, rmpref, ispref}
+## @end deftypefn
+
+## Author: John Donoghue
+
+function dir = prefdir ()
+
+  dir = get_home_directory ();
+
+  if (nargin > 0)
+    if (! exist (dir, "dir"))
+      mkdir (dir);
+    endif
+  endif
+
+endfunction
+
--- a/scripts/prefs/private/prefdir.m	Wed Jun 15 08:56:43 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-## Copyright (C) 2013-2015 John Donoghue
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {} {} prefdir
-## @deftypefnx {} {@var{dir} =} prefdir
-## Return the directory that holds the preferences for Octave.
-##
-## Examples:
-##
-## Display the preferences directory
-##
-## @example
-## prefdir
-## @end example
-##
-## Change to the preferences folder
-##
-## @example
-## cd (prefdir)
-## @end example
-## @seealso{getpref, setpref, addpref, rmpref, ispref}
-## @end deftypefn
-
-## Author: John Donoghue
-
-function dir = prefdir ()
-
-  dir = get_home_directory ();
-
-endfunction
-