forked from marianux/ecg-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnInstallECGkit.m
150 lines (114 loc) · 5.64 KB
/
UnInstallECGkit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
%% Uninstallation script of ECGkit
% Script to install this toolbox.
%
% ****************************************************************
% ** Check the pretty printed help documentation in help folder **
% ****************************************************************
%
% Example
% UnInstallECGkit()
%
%
% See also InstallECGkit
%
% Author: Mariano Llamedo Soria
% <matlab:web('mailto:llamedom@electron.frba.utn.edu.ar','-browser') (email)>
% Version: 0.1 beta
% Birthdate: 01/09/2012
% Last update: 18/10/2014
% Copyright 2008-2015
function UnInstallECGkit( bIgnoreAdminPrivs )
if( nargin < 1 || isempty(bIgnoreAdminPrivs) )
bIgnoreAdminPrivs = false;
end
release_str = 'v0.1.0 beta - 05/05/2015';
backup_string = 'ECGkit_backup';
% get the correct command names in this architecture.
sys_cmds = sys_command_strings();
bMatlab = isMatlab();
bOctave = isOctave();
bUseDesktop = usejava('desktop');
if( bUseDesktop || bOctave )
disp_string_framed('*Blue', sprintf('ECGkit for Matlab %s', release_str) );
if( bMatlab )
% Tab completion of selected functions
% Modify the TC.xml and TC.xsd
bTabUnInstallError = false;
tcxml_filename = fullfile(matlabroot,'toolbox', 'local', 'TC.xml');
tcxsd_filename = fullfile(matlabroot,'toolbox', 'local', 'TC.xsd');
if( exist([tcxml_filename backup_string ], 'file') )
str_command = [ sys_cmds.copy_command ' "' tcxml_filename '" "' tcxml_filename backup_string '"' sys_cmds.command_sep_str ];
else
str_command = [];
end
if( exist([tcxsd_filename backup_string ], 'file') )
str_command = [ str_command sys_cmds.copy_command ' "' tcxsd_filename '" "' tcxsd_filename backup_string '"' ];
end
if( isempty(str_command) )
status = 1;
else
[status, ~] = system( str_command, '-runAsAdmin' );
end
if( status == 0 )
cprintf('*blue', 'Remember to restart Matlab for function''s "tab completion" changes to take effect.\n' );
% cprintf('SystemCommands', '\nIn case something went wrong regarding "tab completion" feature, you can restore the original files:\n%s\n%s\n\nTo the original versions, just removing the ', [tcxml_filename backup_string], [tcxsd_filename backup_string] );
% cprintf('*red', '"%s"', backup_string );
% cprintf('SystemCommands', ' extension.\n\n' );
else
disp_string_framed('*red', 'Could not uninstall tab completion');
cprintf('SystemCommands', 'to uninstall "tab completion" capability it is needed to run this script with administrator/root privileges, or say ' );
cprintf('*red', '"YES"' );
cprintf('SystemCommands', ' when.\nRun Matlab as administrator and execute this script again.\n\n' );
if( ~bIgnoreAdminPrivs )
return
end
end
end
end
%path related constants.
root_path = [fileparts(mfilename('fullpath')) filesep ];
if( bUseDesktop || bOctave )
fprintf(1, 'Removing paths. ' );
end
%path related constants.
default_paths = { ...
[ root_path ';' ]; ...
[ root_path 'common' filesep ';' ]; ...
[ root_path 'help' filesep ';' ]; ...
[ root_path 'common' filesep 'a2hbc' filesep ';' ]; ...
[ root_path 'common' filesep 'a2hbc' filesep 'scripts' filesep ';' ]; ...
[ root_path 'common' filesep 'export_fig' filesep ';' ]; ...
[ root_path 'common' filesep 'wavedet' filesep ';' ]; ...
[ root_path 'common' filesep 'plot2svg' filesep ';' ]; ...
[ root_path 'common' filesep 'ppg' filesep ';' ]; ...
[ root_path 'common' filesep 'prtools' filesep ';' ]; ...
[ root_path 'common' filesep 'prtools_addins' filesep ';' ]; ...
[ root_path 'common' filesep 'bin' filesep ';' ]; ...
[ root_path 'common' filesep 'kur' filesep ';' ]; ...
[ root_path 'common' filesep 'LIBRA' filesep ';' ]; ...
};
cellfun(@(a)(rmpath(a)), default_paths);
if( bUseDesktop || bOctave )
bOk = savepath();
if( bOk == 0 )
fprintf(1, 'done !\n' );
fprintf(1, 'Thanks for trying the kit.\n\nNow you can safely delete %s\n', root_path );
else
if( ispc() )
home_path = [getenv('HOMEDRIVE') getenv('HOMEPATH') ];
elseif( isunix() )
home_path = getenv('HOME');
elseif( ismac() )
home_path = getenv('HOME');
end
if( home_path(end) ~= filesep )
home_path = [home_path filesep];
end
bOk = savepath([home_path 'pathdef.m'] );
if( bOk ~= 0 )
disp_string_framed(2, 'Path Not Saved')
fprintf(2, 'Save path manually to uninstall the ECG-Kit permanently. Deletes all occurrences of %s in your path.\n', root_path);
end
end
end
end