New -find tests -wholename, -prune

This commit is contained in:
2009-04-23 10:32:57 +00:00
parent 28d19db8d0
commit 913db3c429
5 changed files with 119 additions and 64 deletions

View File

@ -6635,7 +6635,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
#ifdef Xorriso_findjob_on_expR
int Exprtest_match(struct XorrisO *xorriso, struct ExprtesT *ftest,
void *node_pt, char *name,
void *node_pt, char *name, char *path,
struct stat *boss_stbuf, struct stat *stbuf, int flag)
/*
return:
@ -6801,11 +6801,18 @@ return:
}
break; case 11: /* -decision */
value= 3;
value= 2;
decision= (char *) arg1;
if(strcmp(decision, "no") == 0 || strcmp(decision, "false") == 0 ||
strcmp(decision, "0") == 0)
value= 2;
if(strcmp(decision, "yes") == 0 || strcmp(decision, "true") == 0)
value= 3;
break; case 12: /* -prune */
value= 1;
ftest->boss->prune= 1;
break; case 13: /* -wholename *arg1 (regex in *arg2) */
ret= regexec(arg2, path, 1, &name_match, 0);
value= !ret;
break; default:
@ -6826,15 +6833,17 @@ ex:;
}
/* @return <0 = error , 0 = no match , 1 = match */
int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
IsoNode *node, char *name,
IsoNode *node, char *name, char *path,
struct stat *boss_stbuf, struct stat *stbuf,
int depth, int flag)
{
int ret;
ret= Findjob_test_2(xorriso, job, node, name, boss_stbuf, stbuf, 1);
if(ret<=0)
job->prune= 0;
ret= Findjob_test_2(xorriso, job, node, name, path, boss_stbuf, stbuf, 1);
if(ret <= 0)
return(ret);
return(1);
}
@ -6842,7 +6851,7 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
#else /* Xorriso_findjob_on_expR */
int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
IsoNode *node, char *name,
IsoNode *node, char *name, char *path,
struct stat *boss_stbuf, struct stat *stbuf,
int depth, int flag)
{
@ -7026,10 +7035,12 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
else
name++;
ret= Xorriso_findi_test(xorriso, job, iso_node, name, NULL, dir_stbuf,
ret= Xorriso_findi_test(xorriso, job, iso_node, name, path, NULL, dir_stbuf,
depth, 0);
if(ret<0)
goto ex;
if(job->prune)
no_dive= 1;
if(ret>0) {
ret= Xorriso_findi_action(xorriso, job,
(IsoDirIter *) boss_iter, boss_mem,
@ -7095,10 +7106,12 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
handling of the find start path with mount points. Dangerous to change.
*/
ret= Xorriso_findi_test(xorriso, job, node, name, dir_stbuf, &stbuf,
ret= Xorriso_findi_test(xorriso, job, node, name, path, dir_stbuf, &stbuf,
depth, 0);
if(ret<0)
goto ex;
if(job->prune)
no_dive= 1;
if(ret>0) {
ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|2|4);
if(ret<=0)