function mlhdlc_demo_setup(demoname)
% Create a tempdir and copy relevant files

%   Copyright 2013-2015 The MathWorks, Inc.

if nargin < 1
    disp('example usage: mlhdlc_demo_setup(''sfir'')');
    return;
end

demoprefix = 'mlhdlc_';

if ~isempty(regexp(demoname, ['^', demoprefix], 'once'))
    dname = demoname;
else
    dname = [demoprefix, demoname];
end

    
srcdir = fullfile(matlabroot, 'toolbox', 'hdlcoder', 'hdlcoderdemos', 'matlabhdlcoderdemos');
tgtdir = fullfile(tempdir, dname);

[~,~,~] = rmdir(tgtdir);
[~,~,~] = mkdir(tgtdir);
cd (tgtdir);

filelist = dir(fullfile(srcdir, [dname, '*.*']));
if isempty(filelist)
    disp(sprintf('no files copied to tempdir...')); %#ok<DSPS>
end

for ii=1:length(filelist)
    copyfile(fullfile(srcdir, filelist(ii).name), pwd, 'f');
end
