deletewithsemaphores.m
来自「Multicore - Parallel Processing on Multi」· M 代码 · 共 36 行
M
36 行
function deletewithsemaphores(fileList)
%DELETEWITHSEMAPHORES Delete files using semaphors.
% DELETEWITHSEMAPHORES(FILELIST) deletes the files in cell array FILELIST
% using semaphores.
%
% Example:
% fileList = {'test1.txt', 'text2.txt'};
% deletewithsemaphores(fileList);
%
% Markus Buehren
% Last modified 09.01.2009
%
% See also SETFILESEMAPHORE, REMOVEFILESEMAPHORE.
checkWaitTime = 0.1;
nrOfAttempts = 10;
if ischar(fileList)
fileList = {fileList};
end
for fileNr = 1:length(fileList)
sem = setfilesemaphore(fileList{fileNr});
for attemptNr = 1:nrOfAttempts
throwError = 0;
showWarnings = (attemptNr == nrOfAttempts); % only in last attempt
if mbdelete(fileList{fileNr}, showWarnings, throwError)
% deleting was successful
break
else
% wait some time and check again
pause(checkWaitTime);
end
end
removefilesemaphore(sem);
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?