Mercurial > repos > public > matlab_path_manager
comparison +mpm/check.m @ 5:6c46515ee860
Add function for checking if the currently loaded paths are correct
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 10 Sep 2018 16:35:17 +0200 |
parents | |
children | 19c4af287596 |
comparison
equal
deleted
inserted
replaced
4:38c29c9ba07f | 5:6c46515ee860 |
---|---|
1 % Check if the current proejct settings are correct | |
2 % The right version is in the path | |
3 % The right version is at the top of the path | |
4 % | |
5 % Useful to put at the top of some scripts | |
6 function check() | |
7 folders = split(path(), pathsep); | |
8 | |
9 sp = mpm.subpaths(); | |
10 for i = 1:length(sp) | |
11 if ~isAtTop(sp{i}, fullfile(pwd, sp{i}), folders) | |
12 error('Subpaths are not correctly set. Try running mpm.set()'); | |
13 end | |
14 end | |
15 end | |
16 | |
17 function b = isAtTop(subpath, fullsubpath, paths) | |
18 for i = 1:length(paths) | |
19 if ~endsWith(paths{i}, subpath) | |
20 continue | |
21 end | |
22 | |
23 b = strcmp(fullsubpath, paths{i}); | |
24 return | |
25 end | |
26 | |
27 b = false; | |
28 end |