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 ...@@ -46,23 +46,18 @@ if ~signalfound
end end
%% Get root of RWTH-ITA-Toolbox %% Get root of RWTH-ITA-Toolbox
tb_setup_path = which( 'ita_toolbox_setup.m' ); tb_setup_path = which('ita_toolbox_setup.m');
tb_base_path = fileparts( tb_setup_path ); 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
%% Add path to kernel, so basic functions are available %% 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 %% Add userpath, here might be our pathdef.m
addpath(userpath); addpath(userpath);
%% ITA-Toolbox path handling %% 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(); ita_path_handling();
%% License and Key? %% 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) ...@@ -47,23 +47,17 @@ if ~isempty(outpathList)
end end
%% Save the path list if possible %% Save the path list if possible
ita_verbose_info('ita_path_handling::Saving Path List...',1); ita_verbose_info('ita_path_handling::Saving path list to your users pathdef.m...',1);
save_state = savepath; upath = userpath();
if save_state == 1 if isempty(upath)
disp('Oh Lord. I cannot save the path list for you. Saving pathdef to your home folder'); userpath('reset');
if isempty( evalin('base','userpath')) end
userpath('reset'); if isempty(userpath())
end 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);
userfolder = evalin('base','userpath'); else
if strcmp(userfolder(end),pathsep) save_state = savepath(fullfile(upath, 'pathdef.m'));
userfolder = userfolder(1:end-1); if save_state == 1
end ita_verbose_info('Oh Lord! I could not write to your users pathdef.m', 0);
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);
end end
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