33 #include <sys/param.h>
34 #include <sys/types.h>
63 while((fP = dP)) {dP = dP->
Next;
delete fP;}
64 while((fP = nP)) {nP = nP->
Next;
delete fP;}
73 int XrdFrmAdmin::Unlink(
const char *
Path)
79 char Resp, lclPath[MAXPATHLEN+8];
84 if (!
Config.LocalPath(
Path, lclPath,
sizeof(lclPath)-8))
85 {numProb++;
return -1;}
90 {Emsg(errno,
"remove ",lclPath); numProb++;
return -1;}
94 if ((
Stat.st_mode & S_IFMT) != S_IFDIR)
95 {
if (Opt.All) {Emsg(ENOTDIR,
"remove ",
Path); numProb++;
return -1;}
96 return UnlinkFile(lclPath);
101 if (!Opt.Recurse)
return UnlinkDir(
Path, lclPath);
107 if (Resp !=
'y')
return Resp !=
'a';
118 {
if ((rc = UnlinkDir(NSE.
nP, NSE.
dP)) < 0)
break;
128 {Emsg(-rc,
"remove directory ", fP->
Path); aOK = 0; numProb++;}
129 else {
if (Opt.Echo) Msg(
"Local directory ",fP->
Path,
" removed.");
140 {Emsg(-rc,
"remove directory ", lclPath); aOK = 0;}
142 if (Opt.Echo) Msg(
"Local directory ", lclPath,
" removed.");
155 int XrdFrmAdmin::UnlinkDir(
const char *
Path,
const char *lclPath)
171 if (rc) {numProb++;
return -1;}
178 if (
unlink(NSE.
nP->
Path)) {Emsg(-rc,
"remove ", lclPath);
return -1;}
180 {Emsg(-rc,
"remove directory ", lclPath); numProb++;
return -1;}
181 if (Opt.Echo) Msg(
"Local directory ",
Path,
" removed.");
191 else {Emsg(EISDIR,
"remove ", fP->
Path); numProb++;
return -1;}
198 if (Resp !=
'y')
return Resp !=
'a';
203 if ((rc = UnlinkDir(NSE.
nP, NSE.
dP)) < 0)
return -1;
220 {fP->
Next = dP; dP = fP;}
221 else {
if (UnlinkFile(fP->
Path) < 0) retval = -1;
235 int XrdFrmAdmin::UnlinkFile(
const char *lclPath)
243 {
if (!
unlink(lclPath) || errno == ENOENT)
return 1;
247 {
if (Opt.Echo) Msg(
"Local file ", lclPath,
" removed.");
256 Emsg(-rc,
"remove ", lclPath);
int stat(const char *path, struct stat *buf)
int unlink(const char *path)
static char Ask(char dflt, const char *Msg1, const char *Msg2="", const char *Msg3="")
static void Rmd(const char *Path, int islfn=0)
static void Rm(const char *Path, int islfn=0)
static theSfx pathType(const char *Path, int chkWhat=chkAll)
virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
NSEnt * Index(int &rc, const char **dPath=0)