Mercurial > repos > public > sbplib
changeset 139:6cf264b023b0
Added script to check all the code in a directory.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 23 Feb 2016 14:21:52 +0100 |
parents | 344bde2f9d9b |
children | 579c348244a0 |
files | checkSbplib.m |
diffstat | 1 files changed, 56 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/checkSbplib.m Tue Feb 23 14:21:52 2016 +0100 @@ -0,0 +1,56 @@ +function [files,res] = checkSbplib() + + + files = collectTargets([]); + + if nargout == 0 + checkcode(files); + return + end + + res = checkcode(files); + + % Remove any empty respones + I = []; + for i = 1:length(res) + if isempty(res{i}) + I(end+1) = i; + end + end + + files(I) = []; + res(I) = []; +end + +function targets = collectTargets(dirPath) + [mfiles, packages] = getFilesAndPackages(dirPath); + + targets = {}; + for i = 1:length(mfiles) + targets{i} = fullfile(dirPath, mfiles{i}); + end + + for i = 1:length(packages) + subtargets = collectTargets(fullfile(dirPath, packages{i})); + targets = [targets subtargets]; + end +end + +function [mfiles, packages] = getFilesAndPackages(dirPath) + if isempty(dirPath) + l = dir(); + else + l = dir(dirPath); + end + + packages = {}; + mfiles = {}; + + for i = 1:length(l) + if l(i).isdir && l(i).name(1) == '+' + packages{end+1} = l(i).name; + elseif ~l(i).isdir && strcmp(l(i).name(end-1:end),'.m') + mfiles{end+1} = l(i).name; + end + end +end \ No newline at end of file