-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFindUserFuncDir.m
39 lines (35 loc) · 1.37 KB
/
FindUserFuncDir.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
function userfuncdir = FindUserFuncDir(obj)
global cfg
cfg = InitConfig(cfg);
userfuncdir = {};
dirnameApp = getAppDir();
rootdirRegsitry = [dirnameApp, 'FuncRegistry/UserFunctions/'];
if ~ispathvalid(rootdirRegsitry)
rootdirRegsitry = filesepStandard([dirnameApp, '../FuncRegistry/UserFunctions/']);
if ~ispathvalid(rootdirRegsitry)
return;
end
end
userfuncdir{1} = rootdirRegsitry;
dirs = dir([userfuncdir{1}, '*']);
for ii = 1:length(dirs)
if ~dirs(ii).isdir
continue
elseif strcmp(dirs(ii).name, '..') || strcmp(dirs(ii).name, '.')
continue
elseif strcmp(dirs(ii).name, 'Archive')
obj.config = struct('InclArchivedFunctions','');
obj.config.InclArchivedFunctions = cfg.GetValue('Include Archived User Functions');
if strcmp(obj.config.InclArchivedFunctions, 'Yes')
userfuncdir{end+1} = fullpath([userfuncdir{1}, 'Archive/']); %#ok<*AGROW>
end
elseif strcmp(dirs(ii).name, 'Sim')
obj.config = struct('InclArchivedFunctions','');
obj.config.InclArchivedFunctions = cfg.GetValue('Include Archived User Functions');
if strcmp(obj.config.InclArchivedFunctions, 'Yes')
userfuncdir{end+1} = fullpath([userfuncdir{1}, 'Sim/']); %#ok<*AGROW>
end
else
userfuncdir{end+1} = filesepStandard(fullpath([userfuncdir{1}, dirs(ii).name]));
end
end