Mercurial > octave
changeset 27902:32f4a15c77c7
what.m: Detect and report on packages (bug #57530)
* what.m: Rename variable 'n' to 'nm' for clarity (name of file).
Add test for packages (nm starts with '+' and is a folder).
Call __display_filenames__ with list of packages.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 03 Jan 2020 09:32:02 -0800 |
parents | 33219a1a6133 |
children | f7279dd915d8 |
files | scripts/miscellaneous/what.m |
diffstat | 1 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/what.m Thu Jan 02 16:08:06 2020 -0800 +++ b/scripts/miscellaneous/what.m Fri Jan 03 09:32:02 2020 -0800 @@ -101,25 +101,28 @@ w.packages = cell (0, 1); for i = 1 : length (files) - n = files{i}; - ## Ignore . and .. - if (strcmp (n, ".") || strcmp (n, "..")) - continue; - else - ## Ignore mdl, slx, p, and packages since they are not - [~, f, e] = fileparts (n); - if (strcmp (e, ".m")) - w.m{end+1} = n; - elseif (strcmp (e, ".mat")) - w.mat{end+1} = n; - elseif (strcmp (e, ".oct")) - w.oct{end+1} = n; - elseif (strcmp (e, mexext ())) - w.mex{end+1} = n; - elseif (n(1) == "@" && isfolder (fullfile (dir, n))) - w.classes{end+1} = n; - endif + nm = files{i}; + + if (strcmp (nm, ".") || strcmp (nm, "..")) + continue; # Ignore . and .. endif + + ## mdl, slx, and p are ignored (no if test) since they are not implemented + [~, f, e] = fileparts (nm); + if (strcmp (e, ".m")) + w.m{end+1} = nm; + elseif (strcmp (e, ".mat")) + w.mat{end+1} = nm; + elseif (strcmp (e, ".oct")) + w.oct{end+1} = nm; + elseif (strcmp (e, mexext ())) + w.mex{end+1} = nm; + elseif (nm(1) == "@" && isfolder (fullfile (dir, nm))) + w.classes{end+1} = nm; + elseif (nm(1) == "+" && isfolder (fullfile (dir, nm))) + w.packages{end+1} = nm; + endif + endfor if (nargout == 0) @@ -128,6 +131,7 @@ __display_filenames__ ("\nMEX-files in directory", w.path, w.mex); __display_filenames__ ("\nOCT-files in directory", w.path, w.oct); __display_filenames__ ("\nClasses in directory", w.path, w.classes); + __display_filenames__ ("\nPackages in directory", w.path, w.packages); else retval = w; endif