New find test -disk_name

This commit is contained in:
Thomas Schmitt 2010-06-19 16:56:15 +00:00
parent cf8f6cb888
commit eb5639b017
8 changed files with 128 additions and 38 deletions

View File

@ -752,7 +752,7 @@ improper_range:;
} }
/* @param flag bit0= -wholename rather than -name /* @param flag bit0-1= 0= -name , 1= -wholename , 2= -disk_name
*/ */
int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag) int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag)
{ {
@ -768,7 +768,11 @@ int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag)
if(ret <= 0) if(ret <= 0)
return(ret); return(ret);
t= o->cursor->test; t= o->cursor->test;
t->test_type= (flag & 1 ? 13 : 1); t->test_type= 1;
if ((flag & 3) == 1)
t->test_type= 13;
else if((flag & 3) == 2)
t->test_type= 16;
name_re= (regex_t *) calloc(1, sizeof(regex_t)); name_re= (regex_t *) calloc(1, sizeof(regex_t));
if(name_re == NULL) if(name_re == NULL)
return(-1); return(-1);

View File

@ -44,6 +44,7 @@ struct ExprtesT {
13= -wholename char *arg1 (regex_t in *arg2) 13= -wholename char *arg1 (regex_t in *arg2)
14= -has_any_xattr 14= -has_any_xattr
15= -has_md5 15= -has_md5
16= -disk_name
*/ */
int test_type; int test_type;
@ -151,6 +152,7 @@ struct FindjoB {
36= make_md5 36= make_md5
37= mkisofs_r 37= mkisofs_r
38= sort_weight number 38= sort_weight number
>>> 39= hide on|iso_rr|joliet|off
*/ */
int action; int action;
int prune; int prune;

View File

@ -1860,6 +1860,10 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
ret= Xorriso_mkisofs_lower_r(xorriso, node, 0); ret= Xorriso_mkisofs_lower_r(xorriso, node, 0);
} else if(action == 38) { /* sort_weight */ } else if(action == 38) { /* sort_weight */
iso_node_set_sort_weight(node, type); iso_node_set_sort_weight(node, type);
} else if(action == 38) { /* hide */
/* >>> iso_node_set_hidden */;
} else { /* includes : 15 in_iso */ } else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0); Xorriso_result(xorriso, 0);
@ -1875,6 +1879,29 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
} }
int Exprtest_match_disk_name(struct XorrisO *xorriso, struct ExprtesT *ftest,
IsoNode *node, int flag)
{
int ret;
char disk_path[SfileadrL], *npt;
regmatch_t name_match;
void *arg2;
ret= Xorriso_retrieve_disk_path(xorriso, node, disk_path, 0);
if(ret <= 0)
return(0);
arg2= ftest->arg2;
npt= strrchr(disk_path, '/');
if(npt != NULL)
npt++;
else
npt= disk_path;
ret= regexec(arg2, npt, 1, &name_match, 0);
return !ret;
}
int Exprtest_match(struct XorrisO *xorriso, struct ExprtesT *ftest, int Exprtest_match(struct XorrisO *xorriso, struct ExprtesT *ftest,
void *node_pt, char *name, char *path, void *node_pt, char *name, char *path,
struct stat *boss_stbuf, struct stat *stbuf, int flag) struct stat *boss_stbuf, struct stat *stbuf, int flag)
@ -2061,6 +2088,9 @@ return:
ret= Xorriso_get_md5(xorriso, node, path, md5, 1); ret= Xorriso_get_md5(xorriso, node, path, md5, 1);
value= (ret > 0); value= (ret > 0);
break; case 16: /* -disk_name *arg1 (regex in *arg2) */
value= !! Exprtest_match_disk_name(xorriso, ftest, node, 0);
break; default: break; default:
/* >>> complain about unknown test type */; /* >>> complain about unknown test type */;

View File

@ -1835,6 +1835,46 @@ int Xorriso__file_start_lba(IsoNode *node,
} }
int Xorriso_retrieve_disk_path(struct XorrisO *xorriso, IsoNode *node,
char disk_path[SfileadrL], int flag)
{
IsoFile *file;
IsoStream *stream= NULL, *input_stream;
char type_text[80], *source_path = NULL;
if(!LIBISO_ISREG(node))
return(0);
/* Obtain most fundamental input stream */
file= (IsoFile *) node;
input_stream= iso_file_get_stream(file);
if(input_stream == NULL)
return(0);
while(1) {
stream= input_stream;
input_stream= iso_stream_get_input_stream(stream, 0);
if(input_stream == NULL)
break;
}
/* Obtain disk path if applicable */
type_text[0]= 0;
Xorriso_stream_type(xorriso, node, stream, type_text, 0);
if(strcmp(type_text, "disk") != 0 && strcmp(type_text, "cout") != 0)
return(0); /* among othersi rejected: "image" */
source_path= iso_stream_get_source_path(stream, 0);
if(source_path == NULL)
return(0);
if(strlen(source_path) >= SfileadrL) {
free(source_path);
return(0);
}
strcpy(disk_path, source_path);
free(source_path);
return(1);
}
int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node, int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node,
char *path, int flag) char *path, int flag)
{ {

View File

@ -87,6 +87,8 @@ int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path,
int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag); int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag);
int Xorriso_retrieve_disk_path(struct XorrisO *xorriso, IsoNode *node,
char disk_path[SfileadrL], int flag);
#endif /* ! Xorriso_pvt_iso_tree_includeD */ #endif /* ! Xorriso_pvt_iso_tree_includeD */

View File

@ -1447,6 +1447,10 @@ Matches if pattern matches the file leaf name.
Matches if pattern matches the file path as it would be printed by action Matches if pattern matches the file path as it would be printed by action
"echo". Character '/' is not special but can be matched by wildcards. "echo". Character '/' is not special but can be matched by wildcards.
.br .br
\fB\-disk_name\fR pattern :
Like -name but testing the leaf name of the file source on disk.
Can be true only for data files which stem not from the loaded image.
.br
\fB\-type\fR type_letter : \fB\-type\fR type_letter :
Matches files of the given type: Matches files of the given type:
"block", "char", "dir", "pipe", "file", "link", "socket", "eltorito", "block", "char", "dir", "pipe", "file", "link", "socket", "eltorito",

View File

@ -1324,6 +1324,10 @@ File: xorriso.info, Node: CmdFind, Next: Filter, Prev: Manip, Up: Options
Matches if pattern matches the file path as it would be Matches if pattern matches the file path as it would be
printed by action "echo". Character '/' is not special but printed by action "echo". Character '/' is not special but
can be matched by wildcards. can be matched by wildcards.
-disk_name pattern :
Like -name but testing the leaf name of the file source on
disk. Can be true only for data files which stem not from
the loaded image.
-type type_letter : -type type_letter :
Matches files of the given type: "block", "char", "dir", Matches files of the given type: "block", "char", "dir",
"pipe", "file", "link", "socket", "eltorito", "Xotic" which "pipe", "file", "link", "socket", "eltorito", "Xotic" which
@ -4071,41 +4075,41 @@ Node: Insert39576
Node: SetInsert47933 Node: SetInsert47933
Node: Manip56500 Node: Manip56500
Node: CmdFind64376 Node: CmdFind64376
Node: Filter73721 Node: Filter73912
Node: Writing78070 Node: Writing78261
Node: SetWrite84359 Node: SetWrite84550
Node: Bootable94643 Node: Bootable94834
Node: Charset102595 Node: Charset102786
Node: Exception105349 Node: Exception105540
Node: DialogCtl109864 Node: DialogCtl110055
Node: Inquiry112209 Node: Inquiry112400
Node: Navigate116349 Node: Navigate116540
Node: Verify123703 Node: Verify123894
Node: Restore132123 Node: Restore132314
Node: Emulation138779 Node: Emulation138970
Node: Scripting145652 Node: Scripting145843
Node: Frontend151214 Node: Frontend151405
Node: Examples152415 Node: Examples152606
Node: ExDevices153584 Node: ExDevices153775
Node: ExCreate154218 Node: ExCreate154409
Node: ExDialog155492 Node: ExDialog155683
Node: ExGrowing156754 Node: ExGrowing156945
Node: ExModifying157556 Node: ExModifying157747
Node: ExBootable158057 Node: ExBootable158248
Node: ExCharset158604 Node: ExCharset158795
Node: ExPseudo159432 Node: ExPseudo159623
Node: ExCdrecord160326 Node: ExCdrecord160517
Node: ExMkisofs160641 Node: ExMkisofs160832
Node: ExGrowisofs161644 Node: ExGrowisofs161835
Node: ExException162768 Node: ExException162959
Node: ExTime163222 Node: ExTime163413
Node: ExIncBackup163681 Node: ExIncBackup163872
Node: ExRestore167153 Node: ExRestore167344
Node: ExRecovery168122 Node: ExRecovery168313
Node: Files168688 Node: Files168879
Node: Seealso169726 Node: Seealso169917
Node: Legal170250 Node: Legal170441
Node: CommandIdx171172 Node: CommandIdx171363
Node: ConceptIdx184473 Node: ConceptIdx184664
 
End Tag Table End Tag Table

View File

@ -1789,6 +1789,10 @@ Matches if pattern matches the file leaf name.
Matches if pattern matches the file path as it would be printed by action Matches if pattern matches the file path as it would be printed by action
"echo". Character '/' is not special but can be matched by wildcards. "echo". Character '/' is not special but can be matched by wildcards.
@* @*
@item -disk_name pattern :
Like -name but testing the leaf name of the file source on disk.
Can be true only for data files which stem not from the loaded image.
@*
@item -type type_letter : @item -type type_letter :
Matches files of the given type: Matches files of the given type:
"block", "char", "dir", "pipe", "file", "link", "socket", "eltorito", "block", "char", "dir", "pipe", "file", "link", "socket", "eltorito",