


PARALLEL CONTEXT In a parallel context, this is a specialized version of rmdir() function. INPUTS o PRCDir [] ... o Parallel [] ... OUTPUTS None 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 dynareParallelRmDir(PRCDir,Parallel) 0002 % PARALLEL CONTEXT 0003 % In a parallel context, this is a specialized version of rmdir() function. 0004 % 0005 % INPUTS 0006 % o PRCDir [] ... 0007 % o Parallel [] ... 0008 % 0009 % OUTPUTS 0010 % None 0011 % 0012 % 0013 % 0014 % Copyright (C) 2009-2011 Dynare Team 0015 % 0016 % This file is part of Dynare. 0017 % 0018 % Dynare is free software: you can redistribute it and/or modify 0019 % it under the terms of the GNU General Public License as published by 0020 % the Free Software Foundation, either version 3 of the License, or 0021 % (at your option) any later version. 0022 % 0023 % Dynare is distributed in the hope that it will be useful, 0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0026 % GNU General Public License for more details. 0027 % 0028 % You should have received a copy of the GNU General Public License 0029 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0030 0031 0032 0033 if nargin ==0, 0034 disp('dynareParallelRmDir(fname)') 0035 return 0036 end 0037 0038 % security check of remote folder delete 0039 ok(1)=isempty(strfind(Parallel_info.RemoteTmpFolder,'..')); 0040 tmp1=strfind(Parallel_info.RemoteTmpFolder,'2'); 0041 ok(2)=tmp1(1)==1; 0042 ok(3)=~isempty(strfind(Parallel_info.RemoteTmpFolder,'-')); 0043 ok(4)=~isempty(strfind(Parallel_info.RemoteTmpFolder,'h')); 0044 ok(5)=~isempty(strfind(Parallel_info.RemoteTmpFolder,'m')); 0045 ok(6)=~isempty(strfind(Parallel_info.RemoteTmpFolder,'s')); 0046 ok(7)=~isempty(PRCDir); 0047 0048 if sum(ok)<7, 0049 error('The name of the remote tmp folder does not comply the security standards!'), 0050 end 0051 0052 for indPC=1:length(Parallel), 0053 ok(1)=isempty(strfind(Parallel(indPC).RemoteDirectory,'..')); 0054 if sum(ok)<7, 0055 error('The remote folder path structure does not comply the security standards!'), 0056 end 0057 while (1) 0058 if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem) 0059 [stat NonServe] = system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir,]); 0060 break; 0061 else 0062 if exist('OCTAVE_VERSION'), % Patch for peculiar behaviour of rmdir under Windows. 0063 % It is necessary because the command rmdir always ask at the user to confirm your decision before 0064 % deleting a directory: this stops the computation! The Octave native function 'confirm_recursive_rmdir' 0065 % disable this mechanism. 0066 val = confirm_recursive_rmdir (false); 0067 [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s'); 0068 0069 else 0070 [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s'); 0071 end 0072 0073 if stat==1, 0074 break, 0075 else 0076 if isempty(dynareParallelDir(PRCDir,'',Parallel)); 0077 break, 0078 else 0079 pause(1); 0080 end 0081 end 0082 end 0083 end 0084 end 0085 0086 return