Mercurial > repos > public > matlab_path_manager
comparison +mpm/verify.m @ 21:02c290e2018c
Refactor ui functions to use the MPM class. Not tested
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 17 Sep 2018 15:49:39 +0200 |
parents | 309cc6c0cd75 |
children | 647cd9e354bf |
comparison
equal
deleted
inserted
replaced
20:ddf75f18509f | 21:02c290e2018c |
---|---|
1 % Check if the current proejct settings are correct | 1 % Check if the current proejct settings are correct |
2 % The right version is in the path | 2 % The right version is in the path |
3 % The right version is at the top of the path | 3 % The right version is at the top of the path |
4 % | 4 % |
5 % Useful to put at the top of some scripts | 5 % Useful to put at the top of some scripts |
6 function check() | 6 function verify(d) |
7 if ~exist('d', 'var') || isempty(d) | 7 if ~exist('d', 'var') || isempty(d) |
8 d = ''; | 8 d = pwd; |
9 end | 9 end |
10 | 10 |
11 folders = split(path(), pathsep); | 11 m = mpm.MatlabPathManager(); |
12 | 12 if ~m.verify(d) |
13 sp = mpm.subpaths(d); | 13 error('Subpaths are not correctly loaded. Try running mpm.checkin()'); |
14 for i = 1:length(sp) | |
15 if ~isAtTop(sp{i}, fullfile(pwd, sp{i}), folders) | |
16 error('Subpaths are not correctly set. Try running mpm.set()'); | |
17 end | |
18 end | 14 end |
19 end | 15 end |
20 | |
21 function b = isAtTop(subpath, fullsubpath, paths) | |
22 for i = 1:length(paths) | |
23 if ~endsWith(paths{i}, subpath) | |
24 continue | |
25 end | |
26 | |
27 b = strcmp(fullsubpath, paths{i}); | |
28 return | |
29 end | |
30 | |
31 b = false; | |
32 end |