Commit ddc4cede authored by Marco Berzborn's avatar Marco Berzborn
Browse files

Changed setup and path handling to save to user's local path.

Avoids writing MATLAB's global pathdef.m. Also fixes issue introduced in 743096db
parent 5e416ad5
......@@ -46,23 +46,18 @@ if ~signalfound
%% Get root of RWTH-ITA-Toolbox
tb_setup_path = which( 'ita_toolbox_setup.m' );
tb_base_path = fileparts( tb_setup_path );
% Switch to user pathdef instead of system-wide pathdef
% (which might open admin permissions dialog and corrupt Matlab for other users)
pathdef_user_path = fullfile( userpath(), 'pathdef.m' );
savepath( pathdef_user_path )
addpath( tb_base_path ); % ... now adds toolbox path to user pathdef.m
tb_setup_path = which('ita_toolbox_setup.m');
tb_base_path = fileparts(tb_setup_path);
%% Add path to kernel, so basic functions are available
addpath([tb_base_path filesep 'kernel']);
addpath([tb_base_path, filesep, 'kernel']);
%% Add userpath, here might be our pathdef.m
%% ITA-Toolbox path handling
% this function has to be in the kernel directory!!!
% this function has to be in the kernel directory!
%% License and Key?
% if exist('ccx','file')
% ccx
% thisFuncStr = [upper(mfilename) ': ']; %#ok<NASGU> Use to show warnings or infos in this functions
% cprintf('blue',[thisFuncStr 'ccx.m clears all and sets warning messages. \n'])
% end
% <ITA-Toolbox>
% This file is part of the ITA-Toolbox. Some rights reserved.
% You can find the license for this m-file in the license.txt file in the ITA-Toolbox folder.
% </ITA-Toolbox>
% Set path
disp('Loading ita_toolbox_path from local pathdef.')
......@@ -47,23 +47,17 @@ if ~isempty(outpathList)
%% Save the path list if possible
ita_verbose_info('ita_path_handling::Saving Path List...',1);
save_state = savepath;
if save_state == 1
disp('Oh Lord. I cannot save the path list for you. Saving pathdef to your home folder');
if isempty( evalin('base','userpath'))
ita_verbose_info('ita_path_handling::Saving path list to your users pathdef.m...',1);
upath = userpath();
if isempty(upath)
userfolder = evalin('base','userpath');
if strcmp(userfolder(end),pathsep)
userfolder = userfolder(1:end-1);
copyfile(fullfile(fullpath,'kernel','StandardRoutines','ita_startup.m'), fullfile(userfolder,'startup.m'))
catch theError
ita_verbose_info('ita_path_handling:writing pathdef unsuccessful, because:',0);
if isempty(userpath())
ita_verbose_info('Oh Lord! I cannot set your userpath. Please check if the default directory exists or manually try saving your path variable.', 0);
save_state = savepath(fullfile(upath, 'pathdef.m'));
if save_state == 1
ita_verbose_info('Oh Lord! I could not write to your users pathdef.m', 0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment