function tmp_name = tempname(dirname)
%TEMPNAME Get temporary file.
%   TEMPNAME returns a unique name, starting with the directory returned by 
%   TEMPDIR, suitable for use as a temporary file.
%
%   TMP_NAME = TEMPNAME(DIRNAME) uses DIRNAME as the directory instead of
%   TEMPDIR.
%
%   See also TEMPDIR.

%   Copyright 1984-2020 The MathWorks, Inc.

if nargin > 0
    dirname = convertStringsToChars(dirname);
end

if nargin == 0
    dirname = tempdir;
elseif ~ischar(dirname) || size(dirname, 1) ~= 1
    error(message('MATLAB:tempname:MustBeString'));
end

tmp_name = fullfile(dirname, ['tp' strrep(char(matlab.lang.internal.uuid),'-','_')]);
