comparison m-toolbox/classes/+utils/@helper/uninstallExtensionsForDir.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % UNINSTALLEXTENSIONSFORDIR uninstalls the toolbox extensions found under the
2 % given directory.
3 %
4 % CALL: utils.helper.uninstallExtensionsForDir(dir)
5 %
6 % M Hewitson 29-10-10
7 %
8 % $Id: uninstallExtensionsForDir.m,v 1.3 2010/12/03 10:00:05 hewitson Exp $
9 %
10 function uninstallExtensionsForDir(varargin)
11
12 extdir = varargin{1};
13
14 if ~ischar(extdir)
15 error('input a path to a directory of LTPDA extensions');
16 end
17
18 fprintf('* uninstalling extensions under %s ...\n', extdir);
19
20 % toolbox path
21 aopath = fileparts(which('ao'));
22 parts = regexp(aopath, '@', 'split');
23 classpath = parts{1};
24
25 % for each user class, look for a corresponding directory and copy any
26 % extension methods in.
27 userclasses = utils.helper.ltpda_userclasses;
28 for ucl = userclasses
29 extsdir = fullfile(extdir, ucl{1});
30 if exist(extsdir, 'dir')==7
31 fprintf(' uninstalling extensions for class %s ...\n', ucl{1});
32 files = utils.prog.filescan(extsdir, '.m');
33 dstdir = fullfile(classpath, ['@' ucl{1}]);
34 for kk=1:numel(files)
35 f = files{kk};
36 [path, name, ext] = fileparts(f);
37 dstfile = fullfile(dstdir, [name ext]);
38 fprintf(' uninstalling extension %s/%s ...\n', ucl{1}, [name ext]);
39 delete(dstfile);
40 end
41 end
42 end
43
44 % Remove any packages from the MATLAB path
45 dirs = utils.prog.dirscan(extdir, '+');
46 for kk=1:numel(dirs)
47 d = dirs{kk};
48 disp([' uninstalling package ' d]);
49 fcnpaths = genpath(fullfile(extdir, d));
50 rmpath(fcnpaths);
51 end
52 rmpath(genpath(extdir));
53 end
54
55