forked from gnu-octave/statistics-resampling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.m
executable file
·46 lines (40 loc) · 1.22 KB
/
uninstall.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
% Basic uninstall script for local installation
%
% Get inst directory
inst_dir = fullfile (fileparts (mfilename ('fullpath')), 'inst');
% Check if running in Octave (else assume Matlab)
info = ver;
isoctave = any (ismember ({info.Name}, 'Octave'));
if isoctave
% Uninstall for Octave
rmpath (inst_dir)
octaverc = '~/.octaverc';
if (exist (octaverc,'file'))
[fid, msg] = fopen (octaverc, 'r+t');
S = (fread (fid, '*char')).';
fclose(fid);
[fid, msg] = fopen (octaverc, 'wt');
else
error('~/.octaverc does not exist');
end
comment = regexptranslate ('escape', '% Load statistics-resampling package');
S = regexprep(S,['\r\n\r\n',comment],'');
S = regexprep(S,strcat('\r\n',...
regexptranslate ('escape', strcat('addpath (''', inst_dir, ''', ''-end'')'))),'');
fseek (fid, 0);
fputs (fid, S);
fclose (fid);
else
% Assumming uninstall for Matlab instead
rmpath (inst_dir)
if exist('savepath')
savepath
else
% backwards compatibility
path2rc;
end
end
% Notify user that uninstall is complete
fprintf ('The statistics-resampling package was uninstalled from the directory:\n%s\n', inst_dir)
% Clean up
clear info isoctave S comment octaverc fid msg inst_dir