function updateFileMap(dstDir, constantParametersOnly)
    % UPDATEFILEMAP
    %   Transform contents of filemap.mat from old releases into a form
    %   consumable in the current release.
    
    % Copyright 2020 The MathWorks, Inc.
    fileMapFile = fullfile(dstDir, 'filemap.mat');
    if isfile(fileMapFile)
        fileMapStruct = load(fileMapFile);
        keys = fileMapStruct.fileMap.keys;
        for kKey = 1:numel(keys)
            v = fileMapStruct.fileMap(keys{kKey});
            if strcmp(v.kind, 'constpdef')
                newv = coder.internal.xrel.transformConstPDef(v);
                fileMapStruct.fileMap(keys{kKey}) = newv;
            elseif constantParametersOnly
                % If we are filtering for constant parameters only then
                % remove entries that are not of kind "constpdef".
                fileMapStruct.fileMap.remove(keys{kKey});    
            end
        end
        
        if fileMapStruct.fileMap.isempty
            % If we ended up removing all entries, then delete the file.
            delete(fileMapFile);
        else
            % Otherwise save the updated map
            save(fileMapFile, '-struct', 'fileMapStruct');
        end
    end
end