function setAllInstrumentationUpToDate...
    (filesToInstrument, sharedUtilIdx, instrumentationUpToDate, ...
                   lInstrPrefix, lOriginalBuildFolder)
%setAllInstrumentationUpToDate updates stored checksums with current values
%    This function operates on both shared library files and files belonging to the main buildInfo.
%    It is a legacy function and wrapper around setInstrumentationUpToDate that will be removed with
%    g2094786.

%   Copyright 2009-2019 The MathWorks, Inc.

filesNonSharedUtil = filesToInstrument(~sharedUtilIdx);

coder.coverage.setInstrumentationUpToDate...
    (filesNonSharedUtil, lInstrPrefix, lOriginalBuildFolder);


filesSharedUtil = filesToInstrument(sharedUtilIdx & ~instrumentationUpToDate);
if ~isempty(filesSharedUtil)
    
    sharedUtilFolder = fileparts(filesSharedUtil{1});
    
    sharedUtilCheckSums = coder.coverage.getInstrFileChecksums(filesSharedUtil);
    sharedUtilCheckSumsStored = ...
        coder.coverage.CodeCoverageHook.coverageInfoFile...
        (sharedUtilFolder, 'read', 'CodeChecksums');
    if isempty(sharedUtilCheckSumsStored)
        sharedUtilCheckSumsNew = sharedUtilCheckSums;
    else
        sharedUtilCheckSumsNew = sharedUtilCheckSumsStored;
        for i=1:length(filesSharedUtil)
            sharedUtilCheckSumsNew(filesSharedUtil{i}) = ...
                sharedUtilCheckSums(filesSharedUtil{i});
        end
    end
    coder.coverage.CodeCoverageHook.coverageInfoFile...
        (sharedUtilFolder, 'write', 'CodeChecksums', sharedUtilCheckSumsNew);
    
    coder.coverage.CodeCoverageHook.coverageInfoFile...
        (sharedUtilFolder, 'write', 'InstrumentationPrefix', lInstrPrefix);
end             


