XRootD
Loading...
Searching...
No Matches
XrdFrmPurgeDir Class Reference
Inheritance diagram for XrdFrmPurgeDir:
Collaboration diagram for XrdFrmPurgeDir:

Public Member Functions

 XrdFrmPurgeDir ()
 ~XrdFrmPurgeDir ()
void isEmpty (struct stat *dStat, const char *dPath, const char *lkFN)
void Reset (time_t dExp)

Public Attributes

time_t expDirTime
time_t lowDirTime
int numEMD
int numRMD

Detailed Description

Definition at line 64 of file XrdFrmPurge.cc.

Constructor & Destructor Documentation

◆ XrdFrmPurgeDir()

XrdFrmPurgeDir::XrdFrmPurgeDir ( )
inline

Definition at line 78 of file XrdFrmPurge.cc.

78{}

◆ ~XrdFrmPurgeDir()

XrdFrmPurgeDir::~XrdFrmPurgeDir ( )
inline

Definition at line 79 of file XrdFrmPurge.cc.

79{}

Member Function Documentation

◆ isEmpty()

void XrdFrmPurgeDir::isEmpty ( struct stat * dStat,
const char * dPath,
const char * lkFN )
virtual

Implements XrdOucNSWalk::CallBack.

Definition at line 86 of file XrdFrmPurge.cc.

88{
89 static const int ossOpts = XRDOSS_isPFN | XRDOSS_resonly;
90 static const char *What = (Config.Test ? "Zorch " : "Purged ");
91 struct stat pStat;
92 struct utimbuf times;
93 char Parent[MAXPATHLEN+1], *Slash;
94 int n, rc;
95
96// Check if this directory is still considered active
97//
98 numEMD++;
99 if (dStat->st_mtime > expDirTime)
100 {if (!lowDirTime || lowDirTime > dStat->st_mtime)
101 lowDirTime = dStat->st_mtime;
102 return;
103 }
104
105// We can expire the directory. However, we need to get the parent mtime
106// because removing this directory should not change the parent's mtime.
107//
108 strcpy(Parent, dPath);
109 n = strlen(Parent);
110 if (Parent[n-1] == '/') Parent[--n] = '\0';
111 if ((Slash = rindex(Parent, '/')))
112 {*Slash = '\0';
113 if (stat(Parent, &pStat)) Slash = 0;
114 }
115
116// Delete the directory
117//
118 if (Config.Test) rc = 0;
119 else if (!(rc = Config.ossFS->Remdir(dPath, ossOpts)) && Slash)
120 {times.actime = pStat.st_atime;
121 times.modtime = pStat.st_mtime;
122 utime(Parent, &times);
123 XrdFrmCns::Rmd(dPath);
124 }
125
126// Report if successful
127//
128 if (!rc)
129 {numRMD++;
130 if (Config.Verbose)
131 {char sbuff[64];
132 struct tm tNow;
133 localtime_r(&(dStat->st_mtime), &tNow);
134 sprintf(sbuff, "%02d%02d%02d %02d:%02d:%02d ",
135 tNow.tm_year-100, tNow.tm_mon+1, tNow.tm_mday,
136 tNow.tm_hour, tNow.tm_min, tNow.tm_sec);
137 Say.Say(What, "empty dir ", sbuff, dPath);
138 }
139 }
140}
#define XRDOSS_isPFN
Definition XrdOss.hh:469
#define XRDOSS_resonly
Definition XrdOss.hh:486
#define stat(a, b)
Definition XrdPosix.hh:96
static void Rmd(const char *Path, int islfn=0)
Definition XrdFrmCns.hh:56
XrdOss * ossFS
virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
XrdSysError Say
XrdFrmConfig Config

References XrdFrm::Config, expDirTime, lowDirTime, numEMD, numRMD, XrdFrmCns::Rmd(), XrdFrc::Say, stat, XRDOSS_isPFN, and XRDOSS_resonly.

Here is the call graph for this function:

◆ Reset()

void XrdFrmPurgeDir::Reset ( time_t dExp)
inline

Definition at line 70 of file XrdFrmPurge.cc.

71 {expDirTime = dExp; lowDirTime = 0; numRMD = numEMD = 0;}

References expDirTime, lowDirTime, numEMD, and numRMD.

Member Data Documentation

◆ expDirTime

time_t XrdFrmPurgeDir::expDirTime

Definition at line 73 of file XrdFrmPurge.cc.

Referenced by isEmpty(), and Reset().

◆ lowDirTime

time_t XrdFrmPurgeDir::lowDirTime

Definition at line 74 of file XrdFrmPurge.cc.

Referenced by isEmpty(), and Reset().

◆ numEMD

int XrdFrmPurgeDir::numEMD

Definition at line 76 of file XrdFrmPurge.cc.

Referenced by isEmpty(), and Reset().

◆ numRMD

int XrdFrmPurgeDir::numRMD

Definition at line 75 of file XrdFrmPurge.cc.

Referenced by isEmpty(), and Reset().


The documentation for this class was generated from the following file: