Home > m > helper > ltpda_filescan.m

ltpda_filescan

PURPOSE ^

LTPDA_FILESCAN recursively scans the given directory for files that end in

SYNOPSIS ^

function files = ltpda_filescan(root_dir, ext)

DESCRIPTION ^

 LTPDA_FILESCAN recursively scans the given directory for files that end in
 'ext' and returns a list of the full paths.
 
 function files = ltpda_filescan(root_dir, ext)
 
 M Hewitson 26-01-07
 
 $Id: ltpda_filescan.html,v 1.1 2007/06/08 14:15:09 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function files = ltpda_filescan(root_dir, ext)
0002 
0003 % LTPDA_FILESCAN recursively scans the given directory for files that end in
0004 % 'ext' and returns a list of the full paths.
0005 %
0006 % function files = ltpda_filescan(root_dir, ext)
0007 %
0008 % M Hewitson 26-01-07
0009 %
0010 % $Id: ltpda_filescan.html,v 1.1 2007/06/08 14:15:09 hewitson Exp $
0011 %
0012 
0013 files = getfiles(root_dir, ext, []);
0014 
0015 %--------------------------------------------------------------------------
0016 function ofiles = getfiles(root_dir, iext, ofiles)
0017 % Recursive function for getting file lists
0018 %
0019 
0020 mdisp('   + looking in %s', root_dir);
0021 files = dir(root_dir);
0022 
0023 for j=1:length(files)
0024   f = files(j);
0025   if f.isdir
0026     if strcmp(f.name,'.')==0 && strcmp(f.name,'..')==0
0027       %mdisp('found dir %s', f.name);
0028       ofiles = getfiles([root_dir '/' f.name], iext, ofiles);
0029     end
0030   else
0031     [pathstr,name,ext,v] = fileparts(f.name);
0032     if strcmp(ext, iext)
0033       ofiles = [ofiles; cellstr([root_dir '/' f.name])];
0034     end
0035   end
0036 end
0037 
0038 % END

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003