


PARALLEL CONTEXT In a parallel context, this function searches recursively through all subdirectories of the given directory 'dirName' and then return a list of all file finds in 'dirName'. INPUTS o dirName [] ... o PRCDir [] ... o Parallel [] ... OUTPUTS o fileList [] ... Copyright (C) 2009-2011 Dynare Team This file is part of Dynare. Dynare is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Dynare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Dynare. If not, see <http://www.gnu.org/licenses/>.


0001 function fileList = dynareParallelListAllFiles(dirName,PRCDir,Parallel) 0002 0003 % PARALLEL CONTEXT 0004 % In a parallel context, this function searches recursively through all subdirectories 0005 % of the given directory 'dirName' and then return a list of all file 0006 % finds in 'dirName'. 0007 % 0008 % 0009 % INPUTS 0010 % o dirName [] ... 0011 % o PRCDir [] ... 0012 % o Parallel [] ... 0013 % 0014 % OUTPUTS 0015 % o fileList [] ... 0016 % 0017 % Copyright (C) 2009-2011 Dynare Team 0018 % 0019 % This file is part of Dynare. 0020 % 0021 % Dynare is free software: you can redistribute it and/or modify 0022 % it under the terms of the GNU General Public License as published by 0023 % the Free Software Foundation, either version 3 of the License, or 0024 % (at your option) any later version. 0025 % 0026 % Dynare is distributed in the hope that it will be useful, 0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0029 % GNU General Public License for more details. 0030 % 0031 % You should have received a copy of the GNU General Public License 0032 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0033 0034 0035 0036 if (~ispc || strcmpi('unix',Parallel.OperatingSystem)) 0037 0038 fileList={}; 0039 currentPath=[]; 0040 0041 % Get the data for the current remote directory. 0042 [Flag fL]=system(['ssh ',Parallel.UserName,'@',Parallel.ComputerName,' ls ',Parallel.RemoteDirectory,'/',PRCDir, ' -R -p -1']); 0043 0044 % Format the return value fL. 0045 0046 nL=regexp(fL,'\n'); 0047 start=1; 0048 j=1; 0049 0050 for (i=1:length(nL)) 0051 0052 stringProcessed=fL(start:nL(i)-1); 0053 0054 if isempty(stringProcessed) 0055 start=nL(i)+1; 0056 continue 0057 end 0058 0059 if strfind(stringProcessed,'/') 0060 if strfind(stringProcessed,PRCDir) 0061 DD=strfind(stringProcessed,':'); 0062 stringProcessed(DD)='/'; 0063 currentPath=stringProcessed; 0064 end 0065 start=nL(i)+1; 0066 continue 0067 end 0068 0069 fileList{j,1}=[currentPath stringProcessed]; 0070 start=nL(i)+1; 0071 j=j+1; 0072 end 0073 0074 0075 else 0076 if (strmatch(dirName, 'Root')==1) % First call in Windows enviroment 0077 dirName=(['\\',Parallel.ComputerName,'\',Parallel.RemoteDrive,'$\',Parallel.RemoteDirectory,'\',PRCDir]); 0078 end 0079 % Get the data for the current directory and exstract from it the index 0080 % for directories: 0081 dirData = dir(dirName); 0082 dirIndex = [dirData.isdir]; 0083 0084 % Get a list of the files: 0085 fileList = {dirData(~dirIndex).name}'; 0086 0087 % Build the path files: 0088 if ~isempty(fileList) 0089 fileList = cellfun(@(x) fullfile(dirName,x),... 0090 fileList,'UniformOutput',false); 0091 end 0092 0093 % Get a list of the subdirectories: 0094 subDirs = {dirData(dirIndex).name}; 0095 0096 % Find index of subdirectories that are not '.' or '..': 0097 validIndex = ~ismember(subDirs,{'.','..'}); 0098 0099 % Loop over valid subdirectories (i.e. all subdirectory without '.' and 0100 % '..': 0101 0102 for iDir = find(validIndex) 0103 % Get the subdirectory path: 0104 nextDir = fullfile(dirName,subDirs{iDir}); 0105 0106 % Recursively call dynareParallelListAllFiles: 0107 fileList = [fileList; dynareParallelListAllFiles(nextDir,PRCDir,Parallel)]; 0108 end 0109 end 0110 0111