function file_names=star_dir_search(filter,lsuf,root_dir)
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
if ~isempty(root_dir), contents=dir(root_dir); else, contents=dir('.'); end
ncont=length(contents);
isd=zeros(1,ncont);
file_names=repmat({},[100,1]);
for jdir=1:ncont,
    isd(jdir)=contents(jdir).isdir;
end
ii_dir=find(isd); ndir=length(ii_dir); nfile=0;
%
if ischar(filter), filter=cellstr(filter); end
for jfilter=1:length(filter),
	for jdir=1:ndir,
        look_dir=[contents(ii_dir(jdir)).name,'\',filter{jfilter}];
        if ~strcmp(look_dir(1),'.'),
            hits=dir([root_dir,look_dir]);
            for jhit=1:length(hits),
                nfile=nfile + 1;
                file_names{nfile,1}=[contents(ii_dir(jdir)).name,'\',hits(jhit).name(1:end-lsuf)];
            end
        end
	end
end
% nfile, file_names
if nfile>0,
    file_names=file_names(1:nfile,1);
end
