%TOOLBOX_EXPORT Prepare toolbox for export, archive and send to website % % TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EXPORTDIR) % % zip and copy toolbox to PRTools server and erchive in EXPORTDIR % % COPYFLAG: TRUE: copy, FALSE: just zip. default TRUE function toolbox_export(toolbox,copyflag,exportdir) if nargin < 3, exportdir = 'K:\insy\PRLab\Matlab\prtools_export'; end if nargin < 2 || isempty(copyflag); copyflag = false; end % create temp dir zipdir = fullfile(fileparts(which(mfilename)),'tmp'); if exist(zipdir,'dir') ~= 7 mkdir(zipdir); end toolboxpath = fileparts(which(fullfile(toolbox,'Contents'))); [~,toolboxname] = fileparts(toolboxpath); toolboxver = ver(toolboxpath); fprintf(1,' Present %s version is %s\n',toolbox,toolboxver(end).Version); pver_new = input([' Give new version number: [' toolboxver(end).Version '] '],'s'); if isempty(pver_new) pver_new = toolboxver(end).Version; end set_version_in_Contents(toolboxpath,pver_new); ztoolbox = fullfile(zipdir,[toolbox pver_new '.' today '.zip']); zip(ztoolbox,{'*.m'},toolboxpath); copyfile(ztoolbox,exportdir); if copyflag ftpsite = ftp('prtools.tudelft.nl','prlab','0iX7&b3c'); cd(ftpsite,'httpdocs/files'); mput(ftpsite,ztoolbox); rename(ftpsite,ztoolbox,[toolboxname '.zip']); disp(' export files have been stored on the website.') disp(' Please check and adjust release notes and known problems on website') close(ftpsite) % backup p-files and m-files fprintf(1,' Storing backups of mfiles and export files ... \n'); [s,mess] = copyfile(ztoolbox,fullfile(exportdir,toolboxname)); if s delete(exppfiles); disp([' export files have been backed-up in ' exportdir]) else disp(mess); end else fprintf(1,' The zip-files have been created in exportdir.\n'); fprintf(1,' They have not been copied to the website!\n'); fprintf(1,' If needed, rerun with flag set.\n'); end function set_version_in_Contents(toolbox,prtv) if ~isstr(prtv) error('Version should be given as string, e.g. ''3.2.7''') end contentfile = fullfile(toolbox,'Contents.m'); s = readf(contentfile); n = findstr(s,prnewline); r = [s(1:n(1)), '% Version ' prtv ' ' date s(n(2):end)]; writf(contentfile,r); disp(' Contents.m rewritten with new version number')