diff --git a/+PlotID/copyUserFCN.m b/+PlotID/copyUserFCN.m index 26f5c7b3dc59a99b5da5c03ace8e0435cdef4fbd..4525737320b5b2347b8dd2caf18c051ac0c6a90a 100644 --- a/+PlotID/copyUserFCN.m +++ b/+PlotID/copyUserFCN.m @@ -1,8 +1,19 @@ function pList = copyUserFCN(scriptPath, folderName, storPath, ID) +%COPYUSERFCN copies all user functions, classes and toolboxes that are used +%by the base script (scriptpath). +% folderName, storPath and ID are required for createfilecopy [fList,pList] = matlab.codetools.requiredFilesAndProducts(scriptPath); fList = fList(~ismember(fList,scriptPath)); % rmv plot script itself from list fList = fList(~contains(fList,'config.json')); % rmv config.json from list fList = removePltIdFiles(fList); % Do not copy files that are part of PlotID + + % copy Classes and Toolboxes as a whole + copyTBorClass(fList,'+', folderName, storPath, ID); % Toolboxes + copyTBorClass(fList,'@', folderName, storPath, ID); % Classes + %remove class and toolbox files from flist + fList = fList(~contains(fList,{'@','+'})); + + % copy User FCN if ~isempty(fList) PlotID.createFileCopy(fList,folderName,storPath,ID,'userFcn'); end @@ -32,4 +43,18 @@ function [fListClean] = removePltIdFiles(fList) PltID_flist = [packageContent.m; Class_flist]; % Comparison and filter fListClean = fList(~ismember(names,PltID_flist)); +end + +function [status, msg] = copyTBorClass(fList,leadChar, folderName, storPath, ID) +%copyTBorClass copies the Toolboxes or Classes that are part of flist +% lead char must be either '@' for Classes or '+' for Toolboxes +if any(contains(fList,leadChar)) + list = fList(contains(fList, leadChar)); + names = extractBetween(list,leadChar,filesep); + paths = extractBefore(list,strcat(leadChar,names)); + fullPaths = strcat(paths,strcat(leadChar,names)); + fullPaths = unique(fullPaths); + [~, status, msg] =PlotID.createFileCopy(fullPaths,... + folderName,storPath,ID,'class'); +end %if end \ No newline at end of file diff --git a/+PlotID/createFileCopy.m b/+PlotID/createFileCopy.m index e876e70926a4e70791d4295d0745e60c9b166d41..10ac4e7100e4143edcf33de37f5d4dd9bddbd05f 100644 --- a/+PlotID/createFileCopy.m +++ b/+PlotID/createFileCopy.m @@ -29,6 +29,8 @@ end case 'userFcn' %keep original name newfile = sprintf([name,ext]); + case {'class','toolbox'} + newfile = name; % copy whole folder otherwise error([type,' is not a valid type for createFileCopy']) end %switch