Mercurial > hg > octave-nkf
view scripts/path/savepath.m @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 76f67400649e |
children |
line wrap: on
line source
## Copyright (C) 2005-2015 Bill Denney ## ## 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 {Function File} {} savepath () ## @deftypefnx {Function File} {} savepath (@var{file}) ## @deftypefnx {Function File} {@var{status} =} savepath (@dots{}) ## Save the unique portion of the current function search path that is ## not set during Octave's initialization process to @var{file}. ## ## If @var{file} is omitted, Octave looks in the current directory for a ## project-specific @file{.octaverc} file in which to save the path ## information. If no such file is present then the user's configuration file ## @file{~/.octaverc} is used. ## ## If successful, @code{savepath} returns 0. ## ## The @code{savepath} function makes it simple to customize a user's ## configuration file to restore the working paths necessary for a particular ## instance of Octave. Assuming no filename is specified, Octave will ## automatically restore the saved directory paths from the appropriate ## @file{.octaverc} file when starting up. If a filename has been specified ## then the paths may be restored manually by calling @code{source @var{file}}. ## @seealso{path, addpath, rmpath, genpath, pathdef} ## @end deftypefn ## Author: Bill Denney <bill@givebillmoney.com> function retval = savepath (file) beginstring = "## Begin savepath auto-created section, do not edit"; endstring = "## End savepath auto-created section"; ## Use project-specific or user's .octaverc when no file specified if (nargin == 0) file = fullfile (pwd, ".octaverc"); if (! exist (file, "file")) file = fullfile ("~", ".octaverc"); endif endif ## Read in the file [filelines, startline, endline] = getsavepath (file); ## Determine where the savepath lines are placed in the file. if (isempty (filelines) || (startline == 1 && endline == length (filelines))) ## savepath is the entire file. pre = post = {}; elseif (endline == 0) ## Drop the savepath statements at the end of the file. pre = filelines; post = {}; elseif (startline == 1) pre = {}; post = filelines(endline+1:end); elseif (endline == length (filelines))