comparison scripts/miscellaneous/what.m @ 27903:f7279dd915d8

what.m: Check file / folder status before returning results (bug #57531). * what.m: Add isfile() or isfolder() checks to make sure that names have the correct identity.
author Rik <rik@octave.org>
date Fri, 03 Jan 2020 09:43:43 -0800
parents 32f4a15c77c7
children 121d33ab44bc
comparison
equal deleted inserted replaced
27902:32f4a15c77c7 27903:f7279dd915d8
108 endif 108 endif
109 109
110 ## mdl, slx, and p are ignored (no if test) since they are not implemented 110 ## mdl, slx, and p are ignored (no if test) since they are not implemented
111 [~, f, e] = fileparts (nm); 111 [~, f, e] = fileparts (nm);
112 if (strcmp (e, ".m")) 112 if (strcmp (e, ".m"))
113 w.m{end+1} = nm; 113 if (isfile (fullfile (dir, nm)))
114 w.m{end+1} = nm;
115 endif
114 elseif (strcmp (e, ".mat")) 116 elseif (strcmp (e, ".mat"))
115 w.mat{end+1} = nm; 117 if (isfile (fullfile (dir, nm)))
118 w.mat{end+1} = nm;
119 endif
116 elseif (strcmp (e, ".oct")) 120 elseif (strcmp (e, ".oct"))
117 w.oct{end+1} = nm; 121 if (isfile (fullfile (dir, nm)))
122 w.oct{end+1} = nm;
123 endif
118 elseif (strcmp (e, mexext ())) 124 elseif (strcmp (e, mexext ()))
119 w.mex{end+1} = nm; 125 if (isfile (fullfile (dir, nm)))
120 elseif (nm(1) == "@" && isfolder (fullfile (dir, nm))) 126 w.mex{end+1} = nm;
121 w.classes{end+1} = nm; 127 endif
122 elseif (nm(1) == "+" && isfolder (fullfile (dir, nm))) 128 elseif (nm(1) == "@")
123 w.packages{end+1} = nm; 129 if (isfolder (fullfile (dir, nm)))
130 w.classes{end+1} = nm;
131 endif
132 elseif (nm(1) == "+")
133 if (isfolder (fullfile (dir, nm)))
134 w.packages{end+1} = nm;
135 endif
124 endif 136 endif
125 137
126 endfor 138 endfor
127 139
128 if (nargout == 0) 140 if (nargout == 0)