function files = pCanonicalizeFileDependenciesList(files)
%

%   Copyright 2009-2017 The MathWorks, Inc.

% The canonical version of a list of file dependencies involves removing
% all empty entries, replacing any on the path with their full path form
% and leaving all the rest unchanged.

nonEmptyEntries = ~cellfun('isempty', files);
files = files(nonEmptyEntries);

for i = 1:numel(files)
    % Get working copy of the file we are looking at
    thisFile = files{i};    
    fullPath = parallel.internal.apishared.AttachedFiles.resolvePath(thisFile);
    if ~isempty(fullPath)
        % Someone returned something useful
        files{i} = fullPath;
    end
end

files = parallel.internal.apishared.AttachedFiles.addAuthFilesIfDeployed( files );
% Make sure that no directories end in a file separator as the behaviour of
% zip with absolute or relative paths is different under these circumstances 
files = regexprep(files, [filesep '\s*$'], '');
