time | Calls | line |
---|
| | 1 | function cdirs = catdirs(caller, varargin)
|
| | 2 | %CATDIRS Concatenate separate strings of directories into one string.
|
| | 3 | % CATDIRS CALLER DIRNAME checks that DIRNAME is a string, removes any
|
| | 4 | % leading or tailing whitespace, and appends a path separator. CALLER is
|
| | 5 | % the name of the calling function, used only when displaying warnings.
|
| | 6 | %
|
| | 7 | % CATDIRS CALLER DIR1 DIR2 DIR3 ... for each input, checks it is a
|
| | 8 | % string, removes any leading or tailing whitespace, and appends a path
|
| | 9 | % separator; and then concatenates all these strings. CALLER is the
|
| | 10 | % name of the calling function, used only when displaying warnings.
|
| | 11 | %
|
| | 12 | % Example:
|
| | 13 | % dirlist = catdirs('addpath', '/home/user/matlab','/home/user/matlab/test');
|
| | 14 |
|
| | 15 | % Copyright 1984-2015 The MathWorks, Inc.
|
| | 16 |
|
< 0.001 | 5 | 17 | n= nargin-1;
|
< 0.001 | 5 | 18 | narginchk(2,Inf);
|
| | 19 |
|
< 0.001 | 5 | 20 | cdirs = '';
|
| | 21 |
|
< 0.001 | 5 | 22 | for i=1:n
|
< 0.001 | 5 | 23 | next = varargin{i};
|
< 0.001 | 5 | 24 | if ~ischar(next)
|
| | 25 | error(message('MATLAB:catdirs:ArgNotString'));
|
< 0.001 | 5 | 26 | end
|
| | 27 | % Remove leading and trailing whitespace
|
< 0.001 | 5 | 28 | trimmedNext = strtrim(next);
|
< 0.001 | 5 | 29 | if ~isempty(trimmedNext)
|
< 0.001 | 5 | 30 | if ~strcmp(trimmedNext, next)
|
| | 31 | [~,caller]=fileparts(caller);
|
| | 32 | switch caller
|
| | 33 | case 'addpath'
|
| | 34 | warning(message('MATLAB:catdirs:AddLeadingTrailingWhitespace', ...
|
| | 35 | trimmedNext, next));
|
| | 36 | case 'rmpath'
|
| | 37 | warning(message('MATLAB:catdirs:RemoveLeadingTrailingWhitespace', ...
|
| | 38 | trimmedNext, next));
|
| | 39 | end
|
< 0.001 | 5 | 40 | end
|
< 0.001 | 5 | 41 | cdirs = [cdirs trimmedNext pathsep]; %#ok<AGROW>
|
< 0.001 | 5 | 42 | end
|
< 0.001 | 5 | 43 | end
|
Other subfunctions in this file are not included in this listing.