-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdufPath.m
43 lines (38 loc) · 1.12 KB
/
dufPath.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
function dufPath(varargin)
if isdeployed
return;
end
P = genpath(dufRoot);
addpath(P);
%Remove some paths we don't need (we remove all directories that start with
% a . or a ]
removePath = [];
[string,remString] = strtok(P,pathsep);
while ~isempty(string);
if ~isempty(strfind(string,[filesep '.'])) || ~isempty(strfind(string,[filesep ']']))
removePath = cat(2,removePath,pathsep,string);
end
[string,remString] = strtok(remString,pathsep); %#ok
end
if ~isempty(removePath)
rmpath(removePath);
end
% Add in the specified ] directories
for iArg = 1:length(varargin)
cArg = varargin{iArg};
cDir = fullfile(dufRoot,cat(2,']',cArg));
assert(logical(exist(cDir,'file')),']%s is not a directory in %s',cArg,dufRoot);
P = genpath(cDir);
addpath(P);
removePath = [];
[string,remString] = strtok(P,pathsep);
while ~isempty(string);
if ~isempty(strfind(string,[filesep '.']))
removePath = cat(2,removePath,pathsep,string);
end
[string,remString] = strtok(remString,pathsep); %#ok
end
if ~isempty(removePath)
rmpath(removePath);
end
end