function ret = ecoderinstalled(modelName)
% ECODERINSTALLED - Check whether Embedded Coder is installed for current
% user.  This includes testing for a license (but NOT checking
% it out) and testing for a particular file associated with ecoder.
% Return 1 if installed, otherwise return 0.


% Copyright 1994-2018 The MathWorks, Inc.
%

% modelName parameter is not used in this function, keep it anyway for
% backwards compatiability.

    mlock;
    persistent pathExist;
    
    if isempty(pathExist)
        %  avoid use exist() to check for the existence of Contents.m to improve performance g560268
        %  pathExist = exist([matlabroot '/toolbox/coder/embeddedcoder/Contents'],'file') == 2;
        pathExist =  ~isempty(dir([matlabroot '/toolbox/coder/embeddedcoder/Contents.m']));     
    end
    
    ret = license('test', 'RTW_Embedded_Coder') && pathExist;
