0001 function status = checkFunctionUniqueness(altDirs)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if nargin<1
0017
0018 ravenDir=findRAVENroot();
0019
0020
0021 temp_res1=dir([ravenDir '/*/*.m']);
0022 temp_res2=dir([ravenDir '/*/*/*.m']);
0023
0024 ravenFunctions={temp_res1.name,temp_res2.name}';
0025 else
0026 if ispc
0027 splitChar = ';';
0028 else
0029 splitChar = ':';
0030 end
0031 altDirs = strsplit(altDirs,splitChar)';
0032 ravenFunctions={};
0033 for i=1:numel(altDirs)
0034 temp_res=dir(fullfile(char(altDirs(i)),'*.m'));
0035 ravenFunctions = [ravenFunctions, temp_res.name];
0036 end
0037 ravenFunctions=ravenFunctions';
0038 ravenDir=altDirs;
0039 end
0040
0041
0042
0043 ravenFunctions=ravenFunctions(~ismember(ravenFunctions,'startup.m'));
0044
0045
0046 if ispc
0047 matlabPaths=regexp(path, ';', 'split')';
0048 elseif isunix
0049 matlabPaths=regexp(path, ':', 'split')';
0050 end
0051
0052 overlapPath={};
0053 overlapFunctions={};
0054 multiRaven=false;
0055 multiFunction=false;
0056
0057 for i=1:numel(matlabPaths)
0058 if ~startsWith(matlabPaths{i},ravenDir)
0059 temp_res=dir([matlabPaths{i} '/*.m']);
0060 if ~isempty(temp_res)
0061 pathFunctions={temp_res.name}';
0062 else
0063 pathFunctions='';
0064 end
0065 if ~isempty(pathFunctions) && ~any(ismember('Contents.m',pathFunctions))
0066 if any(ismember(ravenFunctions,pathFunctions))
0067 if sum(ismember(ravenFunctions,pathFunctions))>(numel(ravenFunctions)/4)
0068 multiRaven=true;
0069 else
0070 multiFunction=true;
0071 overlapPath = [overlapPath, matlabPaths(i)];
0072 overlapFunctions = [overlapFunctions, {ravenFunctions(ismember(ravenFunctions,pathFunctions))}];
0073 end
0074 end
0075 end
0076 end
0077 end
0078
0079 if multiRaven==true || multiFunction == true
0080 if nargout > 0
0081 status = false;
0082 else
0083 fprintf('Fail\n')
0084 end
0085 if multiRaven==true && nargin < 1
0086 error(['Multiple RAVEN versions detected in MATLAB path. Remove all ',...
0087 'RAVEN directories from the MATLAB path with removeRavenFromPath(), ',...
0088 'or manually remove them. Afterwards, re-run checkInstallation']);
0089 elseif multiFunction == true
0090 for i=1:numel(overlapPath)
0091 fprintf([' Duplicate functions in ',regexprep(overlapPath{i},'(\\)','\\$1'),'\n']);
0092 fprintf([' ' strjoin(overlapFunctions{i},'\n ') '\n']);
0093 end
0094 fprintf(' Resolve conflicting functions to avoid unexpected behaviour\n');
0095 end
0096 else
0097 if nargout > 0
0098 status = true;
0099 else
0100 fprintf('Pass\n')
0101 end
0102 end