gusucode.com > apps工具箱matlab源码程序 > apps/+matlab/+internal/+apputil/convertNameToDir.m

    function dirName = convertNameToDir(appname)

% dirName = matlab.internal.apputil.convertNameToDir(appname) converts the
% app name, appname, into a directory name that can be used to install the
% app.  The name will be a valid MATLAB identifier generated by genvarname.
%
% This is an internal function and is not meant to be called directly.
% 
% See also genvarname.

% Copyright 2012 The MathWorks, Inc.

narginchk(1,1);

prohibittedNames = {'private'};
% Prohibit names from becoming too long.  This is an arbitary number based
% on existing app name lengths;
maxLength = 63;

dirName = genvarname(char(cell2mat(regexp(appname, '[\w\s\d]', 'match'))));
dirName = dirName(1:min(length(dirName), maxLength));


if any(strcmpi(dirName, prohibittedNames))
    dirName = [dirName 'app'];
end