1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
function tsgCleanTempFiles(lGrid, lFiles)
%
% tsgCleanTempFiles(lGrid, bFlags)
%
% Cleans the temporary files associated with lGrid, i.e., all files other
% than the _FileG. If lFlags is [], then all files are cleaned. Otherwise
% only the files with entries in lFlags are cleaned, this is done to limit
% unecessary calls to the 'rm' command.
%
% You may call this function, but it exists mostly to be called by other
% functions. In fact, other functions should clean their temp files so you
% should never have to worry about this.
%
% INPUT:
% lGrid: a grid list created by a tsgMake***(...) command (i.e., an
% existing grid)
%
% lFiles: object with fields sFileX, sFileV, sFileO, sFileW, sFileC
% corresponding to the files to be deleted. If the field
% exist, then the file is deleted. If lFiles is omitted, then
% all files are deleted (except the permanent grid file FileG
%
% generate filenames
[sFiles, sTasGrid] = tsgGetPaths();
[sFileG, sFileX, sFileV, sFileO, sFileW, sFileC, sFileL] = tsgMakeFilenames(lGrid);
sFileX = regexprep(sFileX, '\\ ', ' ');
sFileV = regexprep(sFileV, '\\ ', ' ');
sFileO = regexprep(sFileO, '\\ ', ' ');
sFileW = regexprep(sFileW, '\\ ', ' ');
sFileC = regexprep(sFileC, '\\ ', ' ');
sFileL = regexprep(sFileL, '\\ ', ' ');
if (isfield(lFiles, 'all'))
if (exist(sFileX, 'file') == 2)
delete(sFileX);
end
if (exist(sFileV, 'file') == 2)
delete(sFileV);
end
if (exist(sFileO, 'file') == 2)
delete(sFileO);
end
if (exist(sFileW, 'file') == 2)
delete(sFileW);
end
if (exist(sFileC, 'file') == 2)
delete(sFileC);
end
if (exist(sFileL, 'file') == 2)
delete(sFileL);
end
else
if (isfield(lFiles, 'sFileX'))
if (exist(sFileX, 'file') == 2)
delete(sFileX);
end
end
if (isfield(lFiles, 'sFileV'))
if (exist(sFileV, 'file') == 2)
delete(sFileV);
end
end
if (isfield(lFiles, 'sFileO'))
if (exist(sFileO, 'file') == 2)
delete(sFileO);
end
end
if (isfield(lFiles, 'sFileW'))
if (exist(sFileW, 'file') == 2)
delete(sFileW);
end
end
if (isfield(lFiles, 'sFileC'))
if (exist(sFileC, 'file') == 2)
delete(sFileC);
end
end
if (isfield(lFiles, 'sFileL'))
if (exist(sFileL, 'file') == 2)
delete(sFileL);
end
end
end
end
|