function F = copyToPerWorkerFolder(pool, name, filesOrFolders)
% parallel.pool.copyToPerWorkerFolder - copies files and folders to per-worker folders
%    F = parallel.pool.copyToPerWorkerFolder(POOL, SUBFOLDER, FILESORFOLDERS) copies
%    files and folders listed in cell array FILESORFOLDERS to per-worker
%    subfolder SUBFOLDER. Each file listed in FILESORFOLDERS will be placed
%    directly into the per-worker folder SUBFOLDER. Each folder listed in
%    FILESORFOLDERS will have the trailing portion of the folder structure
%    replicated.

% Copyright 2014-2017 The MathWorks, Inc.

% Convert any string inputs to character vectors
[name, filesOrFolders] = convertStringsToChars(name, filesOrFolders);

if ~iscell(filesOrFolders)
    filesOrFolders = {filesOrFolders};
end

validateattributes(pool, {'parallel.Pool'}, {'scalar'});
validateattributes(name, {'char'}, {'row', 'nonempty'});
validateattributes(filesOrFolders, {'cell'}, {'row'});
F = copyToPerWorker(parallel.internal.pool.FolderManagement.getForPool(pool), ...
                    name, filesOrFolders);
end
