📄 deletewithsemaphores.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -