Changeset 157
- Timestamp:
- 01/20/20 14:58:37 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
prextra/toolbox_export.m
r156 r157 1 1 %TOOLBOX_EXPORT Prepare toolbox for export, archive and send to website 2 2 % 3 % TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EX PORTDIR,EXCLUDE)4 % 5 % zip and copy TOOLBOX to PRTools server and archive in EXPORTDIR. In case3 % TOOLBOX_EXPORT(TOOLBOX,COPYFLAG,EXCLUDE,ARCHIVE) 4 % 5 % zip and copy TOOLBOX to PRTools server and archive in ARCHIVE. In case 6 6 % COPYFLAG is false (default) copying to the server is skipped. 7 7 % … … 9 9 % updated. In addition a TOOLBOX_version.txt file is created or updated on 10 10 % the server. Sub-directories of TOOLBOX given as a cell array in EXCLUDE 11 % will not be stored in the zip-file. Other sub-directories will compressed 12 % as they are. In the main toolbox directory just the m-files are used. 11 % will not be stored in the zip-file. Other sub-directories will be 12 % compressed as they are. In the main toolbox directory just the m-files 13 % are used. 13 14 % 14 15 % TOOLBOX should be in the search path and has to be given by the name 15 16 % only. 16 17 % 17 % The default for EXPORTDIR is 'K:\insy\PRLab\Matlab\prtools_export' 18 % The default for ARCHIVE is the prtools_export dir in the group server: 19 % \\srv051.tudelft.net\staff-groups-ewi\insy\PRLab\Matlab\prtools_export 18 20 19 21 % Copyright: R.P.W. Duin 20 22 21 function toolbox_export(toolbox,copyflag,ex portdir,exclude)22 23 if nargin < 4 , exclude = []; end24 if nargin < 3 || isempty(exportdir) 25 exportdir = 'K:\insy\PRLab\Matlab\prtools_export'; 26 end23 function toolbox_export(toolbox,copyflag,exclude,archive) 24 25 if nargin < 4 || isempty(archive) 26 archive = '\\srv051.tudelft.net\staff-groups-ewi\insy\PRLab\Matlab\prtools_export'; 27 end 28 if nargin < 3, exclude = []; end 27 29 if nargin < 2 || isempty(copyflag); copyflag = false; end 28 30 if ischar(exclude), exclude = {exclude}; end 31 32 if exist(archive,'dir') ~= 7 33 error(['Archive directory .\insy\PRLab\Matlab\prtools_export not found.' ... 34 newline 'Define it in the ARCHIVE parameter.']) 35 end 29 36 30 37 % check toolbox 31 38 s = which([toolbox '/Contents.m']); 32 39 if isempty(s) 33 error(['Toolbox ' toolbox ' is not found or has noContents.m file']);40 error(['Toolbox ' toolbox ' is not found in the path or it has no proper Contents.m file']); 34 41 end 35 42 … … 37 44 zipdir = fullfile(fileparts(which(mfilename)),'tmp'); 38 45 makedir(zipdir); 46 if exist(fullfile(zipdir,toolbox),'dir') == 7 47 rmdir(fullfile(zipdir,toolbox),'s'); 48 end 39 49 40 50 % get names and version 41 51 today = datestr(date,'ddmmmyy'); 42 toolbox path= fileparts(which(fullfile(toolbox,'Contents')));43 [~,toolboxname] = fileparts(toolbox path);44 toolboxver = ver(toolbox path);52 toolboxdir = fileparts(which(fullfile(toolbox,'Contents'))); 53 [~,toolboxname] = fileparts(toolboxdir); 54 toolboxver = ver(toolboxdir); 45 55 46 56 % get and set possibly new version number in Content file … … 49 59 if isempty(pver_new) 50 60 pver_new = toolboxver(end).Version; 51 end 52 set_version_in_Contents(toolboxpath,pver_new); 61 else 62 set_version_in_Contents(toolboxdir,pver_new); 63 end 64 65 % use a copy of TOOLBOX for cleaning and compression 66 disp(' Copying, cleaning and compression make take some time ...') 67 copyfile(toolboxdir,fullfile(zipdir,toolbox)); 68 toolboxdir = fullfile(zipdir,toolbox); 53 69 54 70 % zip 55 71 zfilename = [toolbox pver_new '_' today '.zip']; 56 72 ztoolbox = fullfile(zipdir,zfilename); 57 sdir = dirnames(toolboxpath); 73 sdir = dirnames(toolboxdir); 74 for j=1:numel(sdir) % remove all hidden dirs (.svn) 75 rmdir(fullfile(fullfile(toolboxdir,sdir{j}),'.svn'),'s'); 76 end 58 77 if ~isempty(exclude) 59 78 for j=1:numel(exclude) 60 79 n = strmatch(exclude{j},sdir); 61 80 if isempty(n) 62 warning(['Subdirectory ' exclude{j} ' does not exist andis skipped'])81 warning(['Subdirectory ' exclude{j} ' does not exist. Exclusion is skipped']) 63 82 else 64 83 sdir(n) = []; … … 66 85 end 67 86 end 68 zip(ztoolbox,[{'*.m'} sdir{:}],toolbox path);69 70 % create specific archdir for this toolbox71 archdir = fullfile( exportdir,toolboxname);87 zip(ztoolbox,[{'*.m'} sdir{:}],toolboxdir); 88 89 % use or create specific archdir for this toolbox 90 archdir = fullfile(archive,toolboxname); 72 91 makedir(archdir); 73 92 … … 87 106 [s,mess] = copyfile(ztoolbox,archdir); 88 107 if s 89 disp([' export files have been backed-up in' archdir])108 disp([' Export files have been archived in' newline ' ' archdir]) 90 109 else 91 110 disp(mess);
Note: See TracChangeset
for help on using the changeset viewer.