time   | Calls   |  line  | 
|---|
 |  |    1   | function f = fullfile(varargin)
   | 
 |  |    2   | %FULLFILE Build full file name from parts.
   | 
 |  |    3   | %   F = fullfile(FOLDERNAME1, FOLDERNAME2, ..., FILENAME) builds a full
   | 
 |  |    4   | %   file specification F from the folders and file name specified. Input
   | 
 |  |    5   | %   arguments FOLDERNAME1, FOLDERNAME2, etc. and FILENAME can be strings,
   | 
 |  |    6   | %   character vectors, or cell arrays of character vectors. Non-scalar
   | 
 |  |    7   | %   strings and cell arrays of character vectors must all be the same size.
   | 
 |  |    8   | %
   | 
 |  |    9   | %   If any input is a string array, F is a string array. Otherwise, if any
   | 
 |  |   10   | %   input is a cell array, F is a cell array.  Otherwise, F is a character
   | 
 |  |   11   | %   array.
   | 
 |  |   12   | %
   | 
 |  |   13   | %   The output of FULLFILE is conceptually equivalent to character vector
   | 
 |  |   14   | %   horzcat operation:
   | 
 |  |   15   | %
   | 
 |  |   16   | %      F = [FOLDERNAME1 filesep FOLDERNAME2 filesep ... filesep FILENAME]
   | 
 |  |   17   | %
   | 
 |  |   18   | %   except that care is taken to handle the cases when the folders begin or
   | 
 |  |   19   | %   end with a file separator.
   | 
 |  |   20   | %
   | 
 |  |   21   | %   FULLFILE collapses inner repeated file separators unless they appear at 
   | 
 |  |   22   | %   the beginning of the full file specification. FULLFILE also collapses 
   | 
 |  |   23   | %   relative folders indicated by the dot symbol, unless they appear at 
   | 
 |  |   24   | %   the end of the full file specification. Relative folders indicated 
   | 
 |  |   25   | %   by the double-dot symbol are not collapsed.
   | 
 |  |   26   | %
   | 
 |  |   27   | %   To split a full file name into folder parts, use split(f, filesep).
   | 
 |  |   28   | %
   | 
 |  |   29   | %   Examples
   | 
 |  |   30   | %     % To build platform dependent paths to files:
   | 
 |  |   31   | %        fullfile(matlabroot,'toolbox','matlab','general','Contents.m')
   | 
 |  |   32   | %
   | 
 |  |   33   | %     % To build platform dependent paths to a folder:
   | 
 |  |   34   | %        fullfile(matlabroot,'toolbox','matlab',filesep)
   | 
 |  |   35   | %
   | 
 |  |   36   | %     % To build a collection of platform dependent paths to files:
   | 
 |  |   37   | %        fullfile(toolboxdir('matlab'),'iofun',{'filesep.m';'fullfile.m'})
  | 
 |  |   38   | %
   | 
 |  |   39   | %   See also FILESEP, PATHSEP, FILEPARTS, GENPATH, PATH, SPLIT.
   | 
 |  |   40   | 
 
  | 
 |  |   41   | %   Copyright 1984-2016 The MathWorks, Inc.
   | 
 |  |   42   |     
   | 
< 0.001   |    1308   |   43  |     narginchk(1, Inf); 
   | 
  0.007   |    1308   |   44  |     persistent fileSeparator; 
   | 
  0.002   |    1308   |   45  |     if isempty(fileSeparator) 
   | 
 |  |   46   |         fileSeparator = filesep;
   | 
 |  |   47   |     end
   | 
 |  |   48   | 
 
  | 
  0.003   |    1308   |   49  |     theInputs = varargin; 
   | 
 |  |   50   | 
 
  | 
< 0.001   |    1308   |   51  |     containsCellOrStringInput = false; 
   | 
< 0.001   |    1308   |   52  |     containsStringInput = false;  
   | 
 |  |   53   | 
 
  | 
  0.001   |    1308   |   54  |     for i = 1:nargin 
   | 
 |  |   55   | 
 
  | 
  0.003   |    2616   |   56  |         inputElement = theInputs{i}; 
  | 
 |  |   57   |         
   | 
< 0.001   |    2616   |   58  |         containsCellOrStringInput = containsCellOrStringInput || iscell(inputElement); 
   | 
 |  |   59   |         
   | 
< 0.001   |    2616   |   60  |         if isstring(inputElement) 
   | 
 |  |   61   |             containsStringInput = true; 
   | 
 |  |   62   |             containsCellOrStringInput = true; 
   | 
 |  |   63   |             theInputs{i} = convertStringsToChars(theInputs{i});
  | 
 |  |   64   |         end
   | 
 |  |   65   |     
   | 
  0.001   |    2616   |   66  |         if ~ischar(theInputs{i}) && ~iscell(theInputs{i}) && ~isnumeric(theInputs{i}) && ~isreal(theInputs{i}) 
  | 
 |  |   67   |             error(message('MATLAB:fullfile:InvalidInputType'));
  | 
 |  |   68   |         end
   | 
 |  |   69   | 
 
  | 
< 0.001   |    2616   |   70  |     end 
   | 
 |  |   71   |     
   | 
< 0.001   |    1308   |   72  |     f = theInputs{1}; 
  | 
< 0.001   |    1308   |   73  |     try 
   | 
  0.002   |    1308   |   74  |         if nargin == 1 
   | 
 |  |   75   |             if ~isnumeric(f)
   | 
 |  |   76   |                 f = refinePath(f, fileSeparator);
   | 
 |  |   77   |             end
   | 
< 0.001   |    1308   |   78  |         else 
   | 
< 0.001   |    1308   |   79  |             if containsCellOrStringInput 
   | 
 |  |   80   |                 theInputs(cellfun(@(x)~iscell(x)&&isempty(x), theInputs)) = [];
   | 
< 0.001   |    1308   |   81  |             else 
   | 
  0.020   |    1308   |   82  |                 theInputs(cellfun('isempty', theInputs)) = ''; 
  | 
< 0.001   |    1308   |   83  |             end 
   | 
 |  |   84   | 
 
  | 
< 0.001   |    1308   |   85  |             if length(theInputs)>1 
   | 
  0.042   |    1308   |   86  |                 theInputs{1} = ensureTrailingFilesep(theInputs{1}, fileSeparator); 
  | 
< 0.001   |    1308   |   87  |             end 
   | 
< 0.001   |    1308   |   88  |             if ~isempty(theInputs) 
   | 
  0.018   |    1308   |   89  |                 theInputs(2,:) = {fileSeparator}; 
  | 
  0.003   |    1308   |   90  |                 theInputs{2,1} = ''; 
  | 
  0.017   |    1308   |   91  |                 theInputs(end) = ''; 
   | 
< 0.001   |    1308   |   92  |                 if containsCellOrStringInput 
   | 
 |  |   93   |                     f = strcat(theInputs{:});
  | 
< 0.001   |    1308   |   94  |                 else 
   | 
  0.017   |    1308   |   95  |                     f = [theInputs{:}]; 
  | 
< 0.001   |    1308   |   96  |                 end 
   | 
< 0.001   |    1308   |   97  |             end 
   | 
  0.046   |    1308   |   98  |             f = refinePath(f,fileSeparator); 
   | 
  0.003   |    1308   |   99  |         end 
   | 
 |  |  100   |     catch
   | 
 |  |  101   |         locHandleError(theInputs(1,:));
   | 
 |  |  102   |     end
   | 
 |  |  103   |     
   | 
< 0.001   |    1308   |  104  |     if containsStringInput 
   | 
 |  |  105   |         f = string(f);
   | 
 |  |  106   |     end
   | 
  0.004   |    1308   |  107  | end 
   | 
Other subfunctions in this file are not included in this listing.