Home > m > helper > ltpda_filescan.m

ltpda_filescan

PURPOSE ^

LTPDA_FILESCAN recursively scans the given directory for files that end in 'ext'

SYNOPSIS ^

function files = ltpda_filescan(root_dir, ext)

DESCRIPTION ^

 LTPDA_FILESCAN recursively scans the given directory for files that end in 'ext'

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: LTPDA_FILESCAN recursively scans the given directory for files
              that end in 'ext' and returns a list of the full paths.

 CALL:       files = ltpda_filescan(root_dir, ext)

 INPUTS:     root_dir - directory
             ext      - extension of a file (or cell-array of extensions)

 OUTPUTS:    files    - the found file names

 VERSION: $Id: ltpda_filescan.html,v 1.14 2008/03/31 10:27:31 hewitson Exp $

 HISTORY: 26-01-2007 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function files = ltpda_filescan(root_dir, ext)
0002 % LTPDA_FILESCAN recursively scans the given directory for files that end in 'ext'
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: LTPDA_FILESCAN recursively scans the given directory for files
0007 %              that end in 'ext' and returns a list of the full paths.
0008 %
0009 % CALL:       files = ltpda_filescan(root_dir, ext)
0010 %
0011 % INPUTS:     root_dir - directory
0012 %             ext      - extension of a file (or cell-array of extensions)
0013 %
0014 % OUTPUTS:    files    - the found file names
0015 %
0016 % VERSION: $Id: ltpda_filescan.html,v 1.14 2008/03/31 10:27:31 hewitson Exp $
0017 %
0018 % HISTORY: 26-01-2007 M Hewitson
0019 %             Creation
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 
0023 files = getfiles(root_dir, ext, []);
0024 
0025 %--------------------------------------------------------------------------
0026 function ofiles = getfiles(root_dir, iext, ofiles)
0027 % Recursive function for getting file lists
0028 %
0029 
0030 % mdisp('   + looking in %s', root_dir);
0031 files = dir(root_dir);
0032 
0033 for j=1:length(files)
0034   f = files(j);
0035   if f.isdir
0036     if strcmp(f.name,'.')==0 && strcmp(f.name,'..')==0
0037       %mdisp('found dir %s', f.name);
0038       ofiles = getfiles([root_dir '/' f.name], iext, ofiles);
0039     end
0040   else
0041     [pathstr,name,ext,v] = fileparts(f.name);
0042     if any(strcmp(ext, iext))
0043       ofiles = [ofiles; cellstr([root_dir '/' f.name])];
0044     end
0045   end
0046 end
0047 
0048 % END

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003