-
Notifications
You must be signed in to change notification settings - Fork 7
/
uninstall_eq_toolbox.m
113 lines (108 loc) · 3.71 KB
/
uninstall_eq_toolbox.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
function uninstall_eq_toolbox(arg)
%UNINSTALL_EQ_TOOLBOX Uninstall using Toolbox Installer.
%
%Syntax
% uninstall_eq_toolbox(arg);
%
%Description
% UNINSTALL_EQ_TOOLBOX uses Toolbox Installer to uninstall this toolbox.
% It must be run from the top level directory of this toolbox, which must
% contain the file info.ins.
%
% If UNINSTALL_EQ_TOOLBOX is called with no argument, it asks the user for
% confirmation before taking any action.
%
% UNINSTALL_EQ_TOOLBOX first checks if the file pathname.m exists on the current
% Matlab path and can be appended to.
% If so, it asks the user for confirmation and then simply calls the UNINSTALL
% function of Toolbox Installer to update the file pathname.m.
%
% UNINSTALL_EQ_TOOLBOX DIRNAME, that is UNINSTALL_EQ_TOOLBOX('DIRNAME'),
% calls UNINSTALL('DIRNAME'), using DIRNAME as the directory for pathdef.m.
%
% UNINSTALL_EQ_TOOLBOX -, that is UNINSTALL_EQ_TOOLBOX('-'), calls UNINSTALL('-'),
% which displays a dialog box so the user can select the directory to be used for
% pathdef.m.
%
%Notes
% UNINSTALL_EQ_TOOLBOX does not undo everything done by INSTALL_EQ_TOOLBOX.
% In particular, UNINSTALL_EQ_TOOLBOX does not delete pathdef.m or its
% directory, even if these were created by INSTALL_EQ_TOOLBOX.
%
% For Toolbox Installer 2.2 by Rasmus Anthin, see
% Matlab Central File Exchange
% https://au.mathworks.com/matlabcentral/fileexchange/3726-toolbox-installer-2-2
%
%Examples
% > cd ~
% > uninstall_eq_toolbox
% ??? Error using ==> uninstall_eq_toolbox
% Please run uninstall_eq_toolbox from toolbox directory, eg. /c/leopardi/[...]
%
% > cd /c/leopardi/[...]
% > uninstall_eq_toolbox
% Info: Uninstaller will update the file /c/leopardi/matlab/pathdef.m
% Proceed (y/n)? y
% Info: Uninstalled.
%
% > uninstall_eq_toolbox
% Info: Uninstaller will update the file /c/leopardi/matlab/pathdef.m
% Proceed (y/n)? n
%
%See also
% INSTALL_EQ_TOOLBOX, PATHDEF, PATH, Toolbox Installer 2.2.
% Copyright 2024 Paul Leopardi.
% $Revision 1.12 $ $Date 2024-10-20 $
% Copyright 2013 Paul Leopardi
% $Revision 1.11 $ $Date 2013-01-11 $
% Remove 'ver' output argument from calls to fileparts()
% Copyright 2004-2005 Paul Leopardi for the University of New South Wales.
% $Revision 1.10 $ $Date 2005-06-01 $
% Clearly distinguish between info and error messages
% Documentation files renamed
% $Revision 1.00 $ $Date 2005-02-13 $
%
% For licensing, see COPYING.
% For references, see AUTHORS.
% For revision history, see CHANGELOG.
command = mfilename;
[command_dir, ~, ~] = fileparts(mfilename('fullpath'));
wd = pwd;
if ~strcmp(command_dir,wd)
error(['Please run ' command ' from toolbox directory, eg. ' command_dir])
end
if nargin
%
% If user has used an argument, just call install with this argument.
%
install(arg);
return;
end
estr = 'Error: ';
istr = 'Info: ';
was_not_uninstalled_msg = 'Uninstaller cannot continue.';
need_to_specify_msg = 'You will need to specify the directory for pathdef.m';
pathdef_exists = (exist('pathdef','file') == 2);
if pathdef_exists
pathdef_name = which('pathdef');
pathdefid = fopen(pathdef_name,'a');
if pathdefid > 0
fclose(pathdefid);
reply = input([istr 'Uninstaller will update the file ' strrep(pathdef_name,'\','\\') ...
'\nProceed (y/n)? '],'s');
if strcmpi(reply(1),'y')
uninstall;
end
return;
else
disp([estr was_not_uninstalled_msg]);
disp([estr 'Cannot write to the pathdef file ' ...
pathdef_name ' which was found on the Matlab path.']);
error(['Try "' command ' -". ' need_to_specify_msg]);
end
else
disp([estr was_not_uninstalled_msg ' The file pathdef.m was not found.']);
error(['Try "' command ' -". ' need_to_specify_msg]);
end
%
%end function