forked from torbenwendt/razr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrazr_addpath.m
67 lines (56 loc) · 1.76 KB
/
razr_addpath.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function razr_addpath(do_add, do_force)
% RAZR_ADDPATH - Add or remove paths of required RAZR subdirectories.
%
% Usage:
% RAZR_ADDPATH([do_add], [do_force])
%
% Input:
% do_add If true, add paths of all required subdirectories to the search path, otherwise
% remove them (optional parameter, default: true)
% do_force If true, do not rely on persistent flag storing whether path has been added already
% (optional; default: false)
%------------------------------------------------------------------------------
% RAZR engine for Mathwork's MATLAB
%
% Version 0.93
%
% Author(s): Torben Wendt
%
% Copyright (c) 2014-2017, Torben Wendt, Steven van de Par, Stephan Ewert,
% University Oldenburg, Germany.
%
% This work is licensed under the
% Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International
% License (CC BY-NC-ND 4.0).
% To view a copy of this license, visit
% http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to
% Creative Commons, 444 Castro Street, Suite 900, Mountain View, California,
% 94041, USA.
%------------------------------------------------------------------------------
if nargin < 2
do_force = false;
if nargin < 1
do_add = true;
end
end
persistent already_added
if isempty(already_added)
already_added = false;
end
if ((already_added && do_add) || (~already_added && ~do_add)) && ~do_force
return;
elseif do_add
pathfcn = @addpath;
else
pathfcn = @rmpath;
end
razr_path = get_razr_path;
files = dir(razr_path);
fnames_ignore = {'.', '..', '.git'};
for n = 1:length(files)
if ~ismember(files(n).name, fnames_ignore) && files(n).isdir
pathfcn(genpath([razr_path, filesep, files(n).name]));
end
end
pathfcn(razr_path);
already_added = do_add;