matRad_listAllFiles

Purpose ^

matRad function to get all files in arbitrary deep subfolders

Synopsis ^

function fileList = matRad_listAllFiles(dirPath,uiInput)

Description ^

 matRad function to get all files in arbitrary deep subfolders
 
 call
   fileList = matRad_listAllFiles()
   fileList = matRad_listAllFiles(dirPath)
   fileList = matRad_listAllFiles(uiInput)

 input
   dirPath:        (optional) initial folder to start searching
   uiInput:        (optional) if userInteraction is wanted.
                   Use EITHER dirPath or uiInput

 output
   fileList:       Filelist

 References
   -
 Note
                   MATLAB has an internal recursion limit. If you want to
                   list a huge amount of files you may have to: 
                   >> % N = Number of allowed recursions
                   >> set(0,'RecursionLimit',N)
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Copyright 2015 the matRad development team. 
 
 This file is part of the matRad project. It is subject to the license 
 terms in the LICENSE file found in the top-level directory of this 
 distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 
 of the matRad project, including this file, may be copied, modified, 
 propagated, or distributed except according to the terms contained in the 
 LICENSE file.

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

Cross-reference information ^

This function calls: This function is called by:

Source code ^

0001 function fileList = matRad_listAllFiles(dirPath,uiInput)
0002 % matRad function to get all files in arbitrary deep subfolders
0003 %
0004 % call
0005 %   fileList = matRad_listAllFiles()
0006 %   fileList = matRad_listAllFiles(dirPath)
0007 %   fileList = matRad_listAllFiles(uiInput)
0008 %
0009 % input
0010 %   dirPath:        (optional) initial folder to start searching
0011 %   uiInput:        (optional) if userInteraction is wanted.
0012 %                   Use EITHER dirPath or uiInput
0013 %
0014 % output
0015 %   fileList:       Filelist
0016 %
0017 % References
0018 %   -
0019 % Note
0020 %                   MATLAB has an internal recursion limit. If you want to
0021 %                   list a huge amount of files you may have to:
0022 %                   >> % N = Number of allowed recursions
0023 %                   >> set(0,'RecursionLimit',N)
0024 %
0025 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 %
0027 % Copyright 2015 the matRad development team.
0028 %
0029 % This file is part of the matRad project. It is subject to the license
0030 % terms in the LICENSE file found in the top-level directory of this
0031 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0032 % of the matRad project, including this file, may be copied, modified,
0033 % propagated, or distributed except according to the terms contained in the
0034 % LICENSE file.
0035 %
0036 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037 
0038 %% check whether input argument dirPath is parsed
0039     if ~exist('dirPath','var')
0040         if exist('uiInput','var')
0041             if uiInput == 1
0042                 dirPath = uigetdir;
0043             end
0044         else
0045             dirPath = pwd;
0046         end
0047     end
0048     
0049 %% get all files
0050     
0051     % info of main directory
0052     mainDirInfo = dir(dirPath);
0053     % index of subdirectories
0054     dirIx = [mainDirInfo.isdir];
0055     % list all files which are not subDirs
0056     fileList = {mainDirInfo(~dirIx).name}';
0057     if ~isempty(fileList)
0058         % using fullfile to take care on file seperators
0059         fileList = cellfun(@(x) fullfile(dirPath,x),...
0060                            fileList,'UniformOutput',false);
0061     end
0062     % subdirectories
0063     subDirList = {mainDirInfo(dirIx).name};
0064     % list items without '.' or '..'
0065     validIx = ~ismember(subDirList,{'.','..'});
0066     % loop subDir and recall function itself
0067     for ixDir = find(validIx)
0068         % get subDir Path
0069         nextSubDir = fullfile(dirPath,subDirList{ixDir});
0070         fileList = [fileList; matRad_listAllFiles(nextSubDir)];
0071     end
0072 
0073 end

| Generated by m2html © 2005