DELETE_TMPFOLDER Removes folders in the work area. The function removes a folder in the folder set as work area in *atmlab*. See CONFIGURE for information about *atmlab*. A work area is a required setting. Only folders in the work area are removed for safety reasons. FORMAT delete_tmpfolder(tmpfolder) IN tmpfolder Full path of folder to remove.
0001 % DELETE_TMPFOLDER Removes folders in the work area. 0002 % 0003 % The function removes a folder in the folder set as work area in 0004 % *atmlab*. See CONFIGURE for information about *atmlab*. A work area 0005 % is a required setting. Only folders in the work area are removed for 0006 % safety reasons. 0007 % 0008 % FORMAT delete_tmpfolder(tmpfolder) 0009 % 0010 % IN tmpfolder Full path of folder to remove. 0011 0012 % 2011-05-03 Switch to Matlab's rmdir(...,'s') function. (OLE) 0013 % 2005-03-04 WindowsXP and Windows2000 compatibility added by Hermann Berg 0014 % 2005-01-27 Added force (-f) flag to unix remove command. Without this 0015 % the function does not work for users with alias rm='rm -i'. 0016 % Mattias Ekstrom 0017 % 2002-12-20 Created by Patrick Eriksson, based on older version 0018 % in AMI (part of arts-1). 0019 0020 function delete_tmpfolder(tmpfolder) 0021 0022 0023 0024 %== Check that not debug 0025 % 0026 atmlab( 'require', {'DEBUG'} ); 0027 db = atmlab( 'DEBUG' ); 0028 % 0029 if ~isnan(db) && db 0030 return % ---> 0031 end 0032 0033 0034 %=== Require that a work area is set as a personal setting 0035 % 0036 atmlab( 'require', {'WORK_AREA'} ); 0037 workarea = atmlab( 'WORK_AREA' ); 0038 % 0039 if ~ischar( workarea ) 0040 error( 'WORKAREA must be a string' ); 0041 end 0042 0043 if ispc % Windows is not case sensitive for file/path names 0044 if ~strncmpi( workarea, tmpfolder, length(workarea) ) 0045 error('The given directory is not inside the work area.'); 0046 end 0047 else 0048 if ~strncmp( workarea, tmpfolder, length(workarea) ) 0049 error('The given directory is not inside the work area.'); 0050 end 0051 end 0052 0053 if (exist(tmpfolder,'dir')) 0054 [succ,msg] = rmdir(tmpfolder, 's'); 0055 if (~succ), error('atmlab:delete_tmpfolder', msg); end 0056 else 0057 logtext(1, [tmpfolder ' doesn''t exist. Moving on.\n']); 0058 end