cleantempdir_yp

PURPOSE ^

LUKE - Remove all temporary directories created by LUKE where temporary matrices are stored (see make_path_LOCAL.m or equivalent file)

SYNOPSIS ^

function [flag] = cleantempdir_yp(owner,year,month,day)

DESCRIPTION ^

LUKE - Remove all temporary directories created by LUKE where temporary matrices are stored (see make_path_LOCAL.m or equivalent file)

 This function removes all temporary directories created by LUKE where temporary matrices are stored (see make_path_LOCAL.m or equivalent file)

 INPUT

    - owner: name in the system (string) [1,n]
        default: USER environment variable
    - year: year number [1,1]
        default: this year
    - month: month number [1,1]
        default: this month
    - day: day number [1,1]
        default: this month

 OUTPUT

    - flag: number of directories or files removed [1,1]

 by J. Decker (CEA-IRFM) <joan.decker@cea.fr> and   Y. Peysson (CEA-IRFM) <yves.peysson@cea.fr>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [flag] = cleantempdir_yp(owner,year,month,day)
0002 %LUKE - Remove all temporary directories created by LUKE where temporary matrices are stored (see make_path_LOCAL.m or equivalent file)
0003 %
0004 % This function removes all temporary directories created by LUKE where temporary matrices are stored (see make_path_LOCAL.m or equivalent file)
0005 %
0006 % INPUT
0007 %
0008 %    - owner: name in the system (string) [1,n]
0009 %        default: USER environment variable
0010 %    - year: year number [1,1]
0011 %        default: this year
0012 %    - month: month number [1,1]
0013 %        default: this month
0014 %    - day: day number [1,1]
0015 %        default: this month
0016 %
0017 % OUTPUT
0018 %
0019 %    - flag: number of directories or files removed [1,1]
0020 %
0021 % by J. Decker (CEA-IRFM) <joan.decker@cea.fr> and   Y. Peysson (CEA-IRFM) <yves.peysson@cea.fr>
0022 %
0023 if nargin > 4,error('Wrong number of input arguments in cleantempdir_yp.m');end
0024 if nargin == 0,owner = getenv('USER');end
0025 if nargin <= 1,datenum_ref = now;end
0026 if nargin == 2,month = 1;day = 1;datenum_ref = datenum(year,month,day);end
0027 if nargin == 3,day = 1;datenum_ref = datenum(year,month,day);end
0028 if nargin == 4,datenum_ref = datenum(year,month,day);end
0029 %
0030 dkepath = load_structures_yp('dkepath','','');
0031 %
0032 flag = 0;
0033 %
0034 dirini = pwd;
0035 if isempty(dkepath.temppathroot) || strcmp(dkepath.temppathroot,pwd),
0036     disp('WARNING: you cannot delete automatically working directories if the parent directory is your local directory !');
0037     return;
0038 end
0039 %
0040 if isempty(strfind(dkepath.temppathroot,'scratch')) && isempty(strfind(dkepath.temppathroot,'tmp')),
0041     disp('WARNING: you cannot delete automatically working directories if the parent directory is not named ''scratch'' or ''tmp'' !');
0042     return;
0043 end
0044 %
0045 cd(dkepath.temppathroot);
0046 %
0047 dirlist = dir;
0048 for idir = 1:length(dirlist),
0049     list = ls('-al');
0050     if dirlist(idir).isdir,
0051         if ~isempty(strfind(list(1:strfind(list,dirlist(idir).name)),owner)),
0052             if dirlist(idir).datenum <= datenum_ref,
0053                 flag = flag + rmdir(dirlist(idir).name,'s');
0054             end
0055         end
0056     end
0057 end
0058 %
0059 if ~nargout,disp(['---> ',int2str(flag),' directories have been deleted in ',dkepath.temppathroot]);end
0060 %
0061 cd(dirini);
0062

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.