function addNewDirectoryDependency(zipFileData, clientPaths, workerPaths)
% Add a new directory dependency to a parallel pool

% Copyright 2020 The MathWorks, Inc.

% Ensure that the attached files folder exists
attachedFilesFolder = getAttachedFilesFolder();
if ~exist(attachedFilesFolder, 'dir')
    mkdir(attachedFilesFolder);
end

% Write the zip file data to a temporary file
zipFile = [tempname(attachedFilesFolder) '.zip'];
cleanupObj = onCleanup(@() delete(zipFile)); % Delete temporary zip file
zipFileData.deserializeToFile(zipFile);

% Add dependencies from the zip file
pathPairs = [clientPaths; workerPaths];
distcomp.pAddDependenciesFromZipfile(zipFile, pathPairs, attachedFilesFolder);

end
