configMdt

PURPOSE ^

configMdt sets paths for M development toolbox

SYNOPSIS ^

function configMdt(isPermanent, enforce)

DESCRIPTION ^

 configMdt sets paths for M development toolbox

 By default the paths are not added permanently to the MATLAB 
   configuration. Call configElk(1) to add the paths permanently. Call
   configElk(-1) to delete the paths.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function configMdt(isPermanent, enforce)
0002 % configMdt sets paths for M development toolbox
0003 %
0004 % By default the paths are not added permanently to the MATLAB
0005 %   configuration. Call configElk(1) to add the paths permanently. Call
0006 %   configElk(-1) to delete the paths.
0007 
0008 % MDT: MATLAB developement toolbox - for the everyday programmer
0009 %   Copyright (C) 2012 Alexander Reinhold
0010 %
0011 % This program is free software: you can redistribute it and/or modify it
0012 %   under the terms of the GNU Lesser General Public License as published
0013 %   by the Free Software Foundation, either version 3 of the License, or
0014 %   (at your option) any later version.
0015 %
0016 % This program is distributed in the hope that it will be useful, but
0017 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0018 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0019 %   Lesser General Public License for more details.
0020 %
0021 % You should have received a copy of the GNU Lesser General Public License
0022 %   along with this program.  If not, see <http://www.gnu.org/licenses/>.
0023 
0024 %% List of paths
0025 % The trunk of this code folder is not added to ensure that executing
0026 % configElk can only be done from it's own location.
0027 pathList = {'', ...
0028             'variable', ...
0029             'function', ...
0030             'graphic', ...
0031             'database', ...
0032             'tag-parser', ...
0033             ['extern' filesep 'm2html']};
0034         
0035 %% Input handling
0036 % ensure isPermanent exists
0037 if ~exist('isPermanent', 'var')
0038     isPermanent = 0;
0039 end
0040 
0041 if ~exist('enforce', 'var')
0042     enforce = 0;
0043 end
0044 
0045 if enforce ~= 1
0046     switch isPermanent
0047        case 0
0048           disp('The paths of this project are added to search paths.');
0049        case 1
0050           disp('The paths of this project are added permanently to search paths.')
0051           disp('This will also save path modifications you already did this session')
0052           confirm =  input('Is this OK? [Y/N]: ', 's');
0053           disp(' ')
0054        case -1
0055           disp('The paths of this project are removed permanently from search paths.')
0056           disp('This will also save path modifications you already did this session')
0057           confirm =  input('Is this OK? [Y/N]: ', 's');
0058           disp(' ')
0059        otherwise 
0060           error(['The parameter ' num2str(isPermanent) ' has no meaning']);
0061     end
0062 else
0063     confirm = 'y';
0064 end
0065 
0066 %% Caller and m-file location
0067 callLocation = pwd;
0068 myLocation = which('configMdt');
0069 myLocation = myLocation(1:find(myLocation == '/', 1, 'last'));
0070 cd(myLocation);
0071 
0072 %% Path operation
0073 for iPathList = 1:length(pathList)
0074     if isPermanent >= 0
0075         % add paths (temporary, permanently)
0076         addpath(fullfile(cd, pathList{iPathList}));
0077     else
0078         %remove paths (permanently)
0079         rmpath(fullfile(cd, pathList{iPathList}));
0080     end
0081 end
0082 
0083 %% Permanent operation
0084 if abs(isPermanent) == 1  && strcmpi(confirm, 'y')
0085     savepath
0086 end
0087 
0088 %% return
0089 cd(callLocation);

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005