function F = getDataFromPerWorkerFolder(pool, subdir)
% parallel.pool.getDataFromPerWorkerFolder - extracts per-worker folder data 
%    F = parallel.pool.getDataFromPerWorkerFolder(POOL, SUBFOLDER) extracts
%    the data in the per-worker subfolder SUBFOLDER. F is parallel.FevalOnAllFuture 
%    from which the data can be obtained for each worker individually.
%
%    Examples:
%    Consider a worker-side folder structure
%      <per-worker-root>/testing/my_model.slx
%      <per-worker-root>/testing/someData/data1.mat
%      <per-worker-root>/testing/someData/subdir/data1.mat
%    Copy files from the per-worker folder:
%      p = gcp();
%      subdir = 'testing';
%      f = parallel.pool.getDataFromPerWorkerFolder(p, subdir);
%    f is a parallel.FevalOnAllFuture containing the worker id and data. To
%    write this data to disk:
%      destination = '/shared/project/someData';
%      ok = parallel.pool.writePerFolderData(f, destination);
%    This will create the following files on the client:
%      <destination>/<worker_id>/testing/my_model.slx
%      <destination>/<worker_id>/testing/someData/data1.mat
%      <destination>/<worker_id>/testing/someData/subdir/data1.mat
%
%   See also parallel.pool.getDataFromPerHostFolder, 
%   parallel.pool.writePerFolderData.

% Copyright 2016-2017 The MathWorks, Inc.

% Convert any string inputs to character vectors
subdir = convertStringsToChars(subdir);

validateattributes(pool, {'parallel.Pool'}, {'scalar'});
validateattributes(subdir, {'char', 'string'}, {'row', 'nonempty'});
F = getZippedFolderDataFromPerWorker(parallel.internal.pool.FolderManagement.getForPool(pool), ...
                  subdir);
end