function artifactType = determineArtifactFromName(artifact)
%DETERMINEARTIFACTFROMNAME Determine if artifact is a model or project
%based on the result of a call to "which" with the specified artifact.

% Copyright 2012-2018 The MathWorks, Inc.

artifactType = '';
details = which(artifact);
fext = '';
if ~isempty(details)
    [~, ~, fext] = fileparts(details);
end

isMATLABCoderProject = strcmpi(fext, '.prj');
if isMATLABCoderProject
    artifactType = 'project';
    return
end

isSimulinkModel = any(strcmpi(fext, {'.slx', '.mdl'})) || bdIsLoaded(artifact);
if isSimulinkModel
    artifactType = 'model';
    return
end
