Commit ddc4cede authored by Marco Berzborn's avatar Marco Berzborn

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
end
%% 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);
addpath([tb_base_path, filesep, 'kernel']);
%% Add userpath, here might be our pathdef.m
addpath(userpath);
%% ITA-Toolbox path handling
% this function has to be in the kernel directory!!!
% this function has to be in the kernel directory!
ita_path_handling();
%% 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.')
path(pathdef());
......@@ -47,23 +47,17 @@ if ~isempty(outpathList)
end
%% 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'))
userpath('reset');
end
userfolder = evalin('base','userpath');
if strcmp(userfolder(end),pathsep)
userfolder = userfolder(1:end-1);
end
savepath(fullfile(userfolder,'pathdef.m'));
try
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);
disp(theError.message);
ita_verbose_info('ita_path_handling::Saving path list to your users pathdef.m...',1);
upath = userpath();
if isempty(upath)
userpath('reset');
end
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);
else
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);
end
end
......
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