Changed options -ls* to -lsd*, introduced new family of -ls* without d

This commit is contained in:
Thomas Schmitt 2007-12-18 18:00:37 +00:00
parent af44972353
commit 1605300dba
5 changed files with 286 additions and 59 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "December 16, 2007" .TH XORRISO 1 "December 18, 2007"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@ -907,27 +907,47 @@ Tell the current working directory in the ISO image.
Tell the current working directory on local filesystem. Tell the current working directory on local filesystem.
.TP .TP
\fB\-ls\fR iso_rr_pattern [***] \fB\-ls\fR iso_rr_pattern [***]
List files in the ISO image which match shell patterns (i.e. with wildcards '*' List files in the ISO image which match shell patterns
'?' '[a-z]'). (i.e. with wildcards '*' '?' '[a-z]').
If a pattern does not begin with '/' then it is compared with addresses If a pattern does not begin with '/' then it is compared with addresses
relative to -cd, the current working directory in the ISO image. relative to -cd, the current working directory in the ISO image.
Note that this resembles rather shell command ls -d than command ls. .br
Directories are listed by their content rather than as single file item.
.br .br
Pattern expansion may be disabled by command -iso_rr_pattern. Pattern expansion may be disabled by command -iso_rr_pattern.
.TP .TP
\fB\-lsd\fR iso_rr_pattern [***]
Like -ls but listing directories as themselves and not by their content.
This resembles shell command ls -d.
.TP
\fB\-lsl\fR iso_rr_pattern [***]
Like -ls but also list some of the file attributes.
Output format resembles shell command ls -ln.
.TP
\fB\-lsdl\fR iso_rr_pattern [***]
Like -lsd but also list some of the file attributes.
Output format resembles shell command ls -dln.
.TP
\fB\-lsx\fR disk_pattern [***] \fB\-lsx\fR disk_pattern [***]
List files on local filesystem which match shell patterns. Patterns which do List files on local filesystem which match shell patterns. Patterns which do
not begin with '/' are used relative to -cdx, the current working directory in not begin with '/' are used relative to -cdx, the current working directory in
the local filesystem. the local filesystem.
.br .br
Directories are listed by their content rather than as single file item.
.br
Pattern expansion may be disabled by command -disk_pattern. Pattern expansion may be disabled by command -disk_pattern.
.TP .TP
\fB\-ls_l\fR iso_rr_pattern [***] \fB\-lsdx\fR disk_pattern [***]
Like -ls but also list some of the file attributes. Like -lsx but listing directories as themselves and not by their content.
Output format resembles shell command ls -ldn. This resembles shell command ls -d.
.TP .TP
\fB\-ls_lx\fR disk_pattern [***] \fB\-lslx\fR disk_pattern [***]
Like -lsx but also list some of the file attributes. Like -lsx but also listing some of the file attributes.
Output format resembles shell command ls -ln.
.TP
\fB\-lsdlx\fR disk_pattern [***]
Like -lsdx but also listing some of the file attributes.
Output format resembles shell command ls -dln.
.TP .TP
\fB\-du\fR iso_rr_pattern [***] \fB\-du\fR iso_rr_pattern [***]
Recursively list size of directories and files in the ISO image Recursively list size of directories and files in the ISO image

View File

@ -3928,7 +3928,7 @@ int Xorriso_obtain_pattern_files_x(
{ {
int ret, failed_at, follow_mount, follow_links; int ret, failed_at, follow_mount, follow_links;
char adr[SfileadrL], name[SfileadrL], path_data[SfileadrL], *path; char adr[SfileadrL], name[SfileadrL], path_data[SfileadrL], *path;
struct DirseQ *dirseq; struct DirseQ *dirseq= NULL;
struct stat stbuf; struct stat stbuf;
dev_t dir_dev; dev_t dir_dev;
@ -4101,7 +4101,7 @@ int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem,
return(0); return(0);
} }
(*filev)= (char **) calloc(sizeof(char *), count); (*filev)= (char **) calloc(count, sizeof(char *));
if(*filev==NULL) { if(*filev==NULL) {
Xorriso_no_pattern_memory(xorriso, mem, 0); Xorriso_no_pattern_memory(xorriso, mem, 0);
return(-1); return(-1);
@ -4316,7 +4316,7 @@ int Xorriso_opt_args(struct XorrisO *xorriso,
*optv= argv+idx; *optv= argv+idx;
if(*optc<=0 || !do_expand) if(*optc<=0 || !do_expand)
return(1); return(1);
patterns= calloc(sizeof(char *), *optc); patterns= calloc(*optc, sizeof(char *));
if(patterns==NULL) { if(patterns==NULL) {
no_memory:; no_memory:;
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
@ -4736,7 +4736,7 @@ much_too_long:;
mem+= l; mem+= l;
if(l % sizeof(char *)) if(l % sizeof(char *))
mem+= sizeof(char *)-(l % sizeof(char *)); mem+= sizeof(char *)-(l % sizeof(char *));
if(flag&1) /* diving and counting is done further down */ if(flag&1) /* diving and counting is done further below */
continue; continue;
ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, boss_mem, ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, boss_mem,
own_link_stack,2); own_link_stack,2);
@ -4767,7 +4767,7 @@ much_too_long:;
no_sort_possible:; no_sort_possible:;
no_sort= 1; no_sort= 1;
} else { } else {
filev= (char **) calloc(sizeof(char *), filec+1); filev= (char **) calloc(filec+1, sizeof(char *));
if(filev==NULL) if(filev==NULL)
goto no_sort_possible; goto no_sort_possible;
else { else {
@ -4973,16 +4973,83 @@ int Xorriso_format_ls_l(struct XorrisO *xorriso, struct stat *stbuf, int flag)
} }
struct DirentrY {
char *adr;
struct DirentrY *next;
};
int Xorriso_sorted_dir_x(struct XorrisO *xorriso, char *dir_path,
int *filec, char ***filev, off_t boss_mem, int flag)
{
int count= 0, ret;
char name[SfileadrL];
struct DirseQ *dirseq= NULL;
off_t mem;
struct DirentrY *last= NULL, *current= NULL;
*filec= 0;
*filev= NULL;
mem= boss_mem;
ret= Dirseq_new(&dirseq, dir_path, 1);
if(ret<=0)
goto ex;
while(1) { /* loop over directory content */
ret= Dirseq_next_adr(dirseq,name,0);
if(ret==0)
break;
if(ret<0)
goto ex;
mem+= strlen(name)+8+sizeof(struct DirentrY)+sizeof(char *);
if(mem>xorriso->temp_mem_limit)
{ret= 0; goto ex;}
current= (struct DirentrY *) calloc(1, sizeof(struct DirentrY));
if(current==NULL)
{ret= -1; goto ex;}
current->adr= NULL;
current->next= last;
last= current;
last->adr= strdup(name);
if(last->adr==NULL)
{ret= -1; goto ex;}
count++;
}
*filec= count;
if(count==0)
{ret= 1; goto ex;}
(*filev)= (char **) calloc(count, sizeof(char *));
if(*filev==NULL)
{ret= -1; goto ex; }
count= 0;
for(current= last; current!=NULL; current= last) {
last= current->next;
(*filev)[count++]= current->adr;
free((char *) current);
}
Sort_argv(*filec, *filev, 0);
ret= 1;
ex:;
for(current= last; current!=NULL; current= last) {
last= current->next;
free(current->adr);
free((char *) current);
}
return(ret);
}
/* @param flag bit0= long format /* @param flag bit0= long format
bit1= do not print count of nodes bit1= do not print count of nodes
bit2= du format bit2= du format
bit3= print directories as themselves (ls -d)
*/ */
int Xorriso_lsx_filev(struct XorrisO *xorriso, int filec, char **filev, int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd,
off_t boss_mem, int flag) int filec, char **filev, off_t boss_mem, int flag)
{ {
int i, ret, was_error= 0; int i, ret, was_error= 0, dfilec= 0, pass, passes;
char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL]; char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL];
char *rpt, link_target[SfileadrL]; char *rpt, link_target[SfileadrL], **dfilev= NULL;
off_t size; off_t size;
struct stat stbuf; struct stat stbuf;
@ -4992,7 +5059,7 @@ int Xorriso_lsx_filev(struct XorrisO *xorriso, int filec, char **filev,
/* Count valid nodes, warn of invalid ones */ /* Count valid nodes, warn of invalid ones */
for(i= 0; i<filec; i++) { for(i= 0; i<filec; i++) {
ret= Xorriso_make_pattern_adr(xorriso, xorriso->wdx, filev[i], path, 1|4); ret= Xorriso_make_pattern_adr(xorriso, wd, filev[i], path, 1|4);
if(ret<=0) { if(ret<=0) {
was_error++; was_error++;
continue; continue;
@ -5007,15 +5074,17 @@ int Xorriso_lsx_filev(struct XorrisO *xorriso, int filec, char **filev,
} }
} }
if(!(flag&(2|4))) { if((flag&8) && !(flag&(2|4))) {
sprintf(xorriso->info_text,"Valid local files found: %d\n",filec-was_error); sprintf(xorriso->info_text,"Valid local files found: %d\n",filec-was_error);
Xorriso_info(xorriso,1); Xorriso_info(xorriso,1);
if(filec-was_error<=0) if(filec-was_error<=0)
return(!was_error); return(!was_error);
} }
passes= 1+!(flag&(4|8));
for(pass= 0; pass<passes; pass++)
for(i= 0; i<filec && !(xorriso->request_to_abort); i++) { for(i= 0; i<filec && !(xorriso->request_to_abort); i++) {
ret= Xorriso_make_pattern_adr(xorriso, xorriso->wdx, filev[i], path, 1|4); ret= Xorriso_make_pattern_adr(xorriso, wd, filev[i], path, 1|4);
if(ret<=0) if(ret<=0)
continue; continue;
ret= lstat(path, &stbuf); ret= lstat(path, &stbuf);
@ -5026,8 +5095,36 @@ int Xorriso_lsx_filev(struct XorrisO *xorriso, int filec, char **filev,
ret= stat(path, &stbuf); ret= stat(path, &stbuf);
if(ret==-1) if(ret==-1)
ret= lstat(path, &stbuf); ret= lstat(path, &stbuf);
}
if(ret==-1) if(ret==-1)
continue;
}
if(S_ISDIR(stbuf.st_mode) && !(flag&(4|8))) {
if(pass==0)
continue;
if(filec>1) {
strcpy(xorriso->result_line, "\n");
Xorriso_result(xorriso,0);
sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0));
Xorriso_result(xorriso,0);
}
ret= Xorriso_sorted_dir_x(xorriso, path, &dfilec, &dfilev, boss_mem, 0);
if(ret<=0) {
/* >>> DirseQ loop and single item Xorriso_lsx_filev() */;
} else {
if(flag&1) {
sprintf(xorriso->result_line, "total %d\n", dfilec);
Xorriso_result(xorriso,0);
}
Xorriso_lsx_filev(xorriso, path,
dfilec, dfilev, boss_mem, (flag&1)|2|8);
}
if(dfilec>0)
Sfile_destroy_argv(&dfilec, &dfilev, 0);
continue;
} else
if(pass>0)
continue; continue;
link_target[0]= 0; link_target[0]= 0;
rpt[0]= 0; rpt[0]= 0;
@ -6145,17 +6242,20 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" marked by [***]. \"ls\" restricts it to -ls and -du.", " marked by [***]. \"ls\" restricts it to -ls and -du.",
" -disk_pattern \"on\"|\"ls\"|\"off\"", " -disk_pattern \"on\"|\"ls\"|\"off\"",
" Enable or disable pattern expansions for local filesystem", " Enable or disable pattern expansions for local filesystem",
" commands marked by [***]. \"ls\" restricts to -lsx and -dux.", " commands marked by [***]. \"ls\" restricts to -ls*x and -du*x.",
"", "",
" -ls pattern [***] lists files of the ISO image which match one of the", " -ls pattern [***] lists files of the ISO image which match one of the",
" given shell parser patterns. (I.e. wildcards '*' '?')", " given shell parser patterns. (I.e. wildcards '*' '?').",
" -lsi pattern [***] same as -ls.", " Directories are listed by their content.",
" -lsx pattern [***] lists files of the local filesystem which match one", " -lsd pattern [***] like -ls but listing directories as single items.",
" of the patterns.", " -lsl pattern [***] like -ls but also telling some file attributes.",
" -lsdl pattern [***] like -lsd but also telling some file attributes.",
"", "",
" -ls_l pattern [***] like -ls but also telling some file attributes.", " -lsx pattern [***] lists files of the local filesystem which match one",
" -ls_li pattern [***] same as -ls_l.", " of the patterns. Directories are listed by their content.",
" -ls_lx pattern [***] like -lsx but also telling some file attributes.", " -lsdx pattern [***] like -lsx but listing directories as single items.",
" -lslx pattern [***] like -lsx but also telling some file attributes.",
" -lsdlx pattern [***] like -lsdx but also telling some file attributes.",
"", "",
" -du pattern [***] recursively lists sizes of files or directories in the", " -du pattern [***] recursively lists sizes of files or directories in the",
" ISO image which match one of the shell parser patterns.", " ISO image which match one of the shell parser patterns.",
@ -6298,6 +6398,7 @@ int Xorriso_option_j_capital(struct XorrisO *xorriso, int flag)
@param flag bit0= long format (-ls_l , -du) @param flag bit0= long format (-ls_l , -du)
bit1= do not expand patterns but use literally bit1= do not expand patterns but use literally
bit2= du rather than ls bit2= du rather than ls
bit3= list directories as themselves (ls -d)
*/ */
int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag) int *idx, int flag)
@ -6314,7 +6415,7 @@ int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv,
if((flag&2) && nump>0 ) { if((flag&2) && nump>0 ) {
; ;
} else if(nump <= 0) { } else if(nump <= 0) {
patterns= calloc(sizeof(char *), 1); patterns= calloc(1, sizeof(char *));
if(patterns == NULL) { if(patterns == NULL) {
no_memory:; no_memory:;
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
@ -6326,7 +6427,7 @@ no_memory:;
patterns[0]= "*"; patterns[0]= "*";
flag&= ~2; flag&= ~2;
} else { } else {
patterns= calloc(sizeof(char *), nump); patterns= calloc(nump, sizeof(char *));
if(patterns==NULL) if(patterns==NULL)
goto no_memory; goto no_memory;
for(i= 0; i<nump; i++) { for(i= 0; i<nump; i++) {
@ -6337,7 +6438,8 @@ no_memory:;
} }
} }
if(flag&2) { if(flag&2) {
ret= Xorriso_ls_filev(xorriso, nump, argv + (*idx), mem, flag&(1|4)); ret= Xorriso_ls_filev(xorriso, xorriso->wdi, nump, argv + (*idx), mem,
flag&(1|4|8));
} else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){ } else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){
/* save temporary memory by calling simpler function */ /* save temporary memory by calling simpler function */
ret= Xorriso_ls(xorriso, (flag&1)|4); ret= Xorriso_ls(xorriso, (flag&1)|4);
@ -6346,7 +6448,8 @@ no_memory:;
&mem, 0); &mem, 0);
if(ret<=0) if(ret<=0)
{ret= 0; goto ex;} {ret= 0; goto ex;}
ret= Xorriso_ls_filev(xorriso, filec, filev, mem, flag&(1|4)); ret= Xorriso_ls_filev(xorriso, xorriso->wdi, filec, filev, mem,
flag&(1|4|8));
} }
if(ret<=0) if(ret<=0)
{ret= 0; goto ex;} {ret= 0; goto ex;}
@ -6361,11 +6464,12 @@ ex:;
} }
/* Options -lsx , -ls_lx , /* Options -lsdx , -lsdlx ,
-dux , -du_sx -dux , -du_sx
@param flag bit0= long format (-ls_lx , -dux) @param flag bit0= long format (-ls_lx , -dux)
bit1= do not expand patterns but use literally bit1= do not expand patterns but use literally
bit2= du rather than ls bit2= du rather than ls
bit3= list directories as themselves (ls -d)
*/ */
int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv, int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag) int *idx, int flag)
@ -6382,7 +6486,7 @@ int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv,
if((flag&2) && nump>0) { if((flag&2) && nump>0) {
; ;
} else if(nump <= 0) { } else if(nump <= 0) {
patterns= calloc(sizeof(char *), 1); patterns= calloc(1, sizeof(char *));
if(patterns == NULL) { if(patterns == NULL) {
no_memory:; no_memory:;
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
@ -6394,7 +6498,7 @@ no_memory:;
patterns[0]= "*"; patterns[0]= "*";
flag&= ~2; flag&= ~2;
} else { } else {
patterns= calloc(sizeof(char *), nump); patterns= calloc(nump, sizeof(char *));
if(patterns==NULL) if(patterns==NULL)
goto no_memory; goto no_memory;
for(i= 0; i<nump; i++) { for(i= 0; i<nump; i++) {
@ -6405,7 +6509,8 @@ no_memory:;
} }
} }
if(flag&2) { if(flag&2) {
ret= Xorriso_lsx_filev(xorriso, nump, argv + (*idx), mem, flag&(1|4)); ret= Xorriso_lsx_filev(xorriso, xorriso->wdx,
nump, argv + (*idx), mem, flag&(1|4));
#ifdef Not_yeT #ifdef Not_yeT
} else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){ } else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){
@ -6418,7 +6523,7 @@ no_memory:;
&mem, 0); &mem, 0);
if(ret<=0) if(ret<=0)
{ret= 0; goto ex;} {ret= 0; goto ex;}
ret= Xorriso_lsx_filev(xorriso, filec, filev, mem, flag&(1|4)); ret= Xorriso_lsx_filev(xorriso, xorriso->wdx, filec, filev, mem,flag&(1|4));
} }
if(ret<=0) if(ret<=0)
{ret= 0; goto ex;} {ret= 0; goto ex;}
@ -7418,13 +7523,18 @@ next_command:;
ret= Xorriso_option_j_capital(xorriso, 0); ret= Xorriso_option_j_capital(xorriso, 0);
} else if(strcmp(cmd,"ls")==0 || strcmp(cmd,"lsi")==0 || } else if(strcmp(cmd,"ls")==0 || strcmp(cmd,"lsi")==0 ||
strcmp(cmd,"ls_l")==0 || strcmp(cmd,"ls_li")==0 || strcmp(cmd,"lsl")==0 || strcmp(cmd,"lsli")==0) {
strcmp(cmd,"ls-l")==0 || strcmp(cmd,"ls-li")==0) { ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]=='l'));
ret= Xorriso_option_lsi(xorriso, argc, argv, idx, strlen(cmd)>3);
} else if(strcmp(cmd,"lsx")==0 || strcmp(cmd,"ls_lx")==0 } else if(strcmp(cmd,"lsd")==0 || strcmp(cmd,"lsdi")==0 ||
|| strcmp(cmd,"ls-lx")==0) { strcmp(cmd,"lsdl")==0 || strcmp(cmd,"lsdli")==0) {
ret= Xorriso_option_lsx(xorriso, argc, argv, idx, strlen(cmd)>3); ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[3]=='l')|8);
} else if(strcmp(cmd,"lsdx")==0 || strcmp(cmd,"lsdlx")==0) {
ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[3]=='l')|8);
} else if(strcmp(cmd,"lsx")==0 || strcmp(cmd,"lslx")==0) {
ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]=='l'));
} else if(strcmp(cmd,"logfile")==0) { } else if(strcmp(cmd,"logfile")==0) {
(*idx)+= 2; (*idx)+= 2;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.12.16.144615" #define Xorriso_timestamP "2007.12.18.175924"

View File

@ -1704,9 +1704,10 @@ dir_not_removed:;
while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4))) while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4)))
&& !xorriso->request_not_to_ask) { && !xorriso->request_not_to_ask) {
Xorriso_ls_filev(xorriso, 1, &path, (off_t) 0, 1|2); /* ls -l */ /* ls -ld */
if(is_dir) Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 1|2|8);
Xorriso_ls_filev(xorriso, 1, &path, (off_t) 0, 2|4); /* du -s */ if(is_dir) /* du -s */
Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 2|4);
if(flag&8) if(flag&8)
sprintf(xorriso->info_text, sprintf(xorriso->info_text,
"File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n"); "File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n");
@ -1994,18 +1995,79 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
} }
int Xorriso_sorted_dir_i(struct XorrisO *xorriso,
struct iso_tree_node_dir *dir_node,
int *filec, char ***filev, off_t boss_mem, int flag)
{
int i,j,ret;
struct iso_tree_iter *iter= NULL;
struct iso_tree_node *node;
char *name;
off_t mem;
(*filec)= 0;
(*filev)= NULL;
iter= iso_tree_node_children(dir_node);
if(iter==NULL) {
cannot_iter:;
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
{ret= -1; goto ex;}
}
mem= 0;
for(i= 0; (node= iso_tree_iter_next(iter)) != NULL; ) {
name= (char *) iso_tree_node_get_name(node);
mem+= sizeof(char *)+strlen(name)+8;
(*filec)++;
}
iso_tree_iter_free(iter);
if(*filec==0)
{ret= 1; goto ex;}
ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2);
if(ret<=0)
goto ex;
(*filev)= (char **) calloc(*filec, sizeof(char *));
if(*filev==NULL)
{ret= -1; goto ex; }
iter= iso_tree_node_children(dir_node);
if(iter==NULL)
goto cannot_iter;
for(i= 0; i<*filec; i++) {
name= (char *) iso_tree_node_get_name(iso_tree_iter_next(iter));
(*filev)[i]= strdup(name);
if((*filev)[i]==NULL) {
for(j= 0; j<i; j++)
if((*filev)[j]!=NULL)
free((*filev)[j]);
free((char *) (*filev));
ret= -1; goto ex;
}
}
Sort_argv(*filec, *filev, 0);
ret= 1;
ex:;
if(iter!=NULL)
iso_tree_iter_free(iter);
return(ret);
}
/* @param flag bit0= long format /* @param flag bit0= long format
bit1= do not print count of nodes bit1= do not print count of nodes
bit2= du format bit2= du format
bit3= print directories as themselves (ls -d)
*/ */
int Xorriso_ls_filev(struct XorrisO *xorriso, int filec, char **filev, int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
off_t boss_mem, int flag) int filec, char **filev, off_t boss_mem, int flag)
{ {
int i, ret, was_error= 0; int i, ret, was_error= 0, dfilec= 0, pass, passes;
struct iso_tree_node *node; struct iso_tree_node *node;
struct iso_volume *volume; struct iso_volume *volume;
char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL]; char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL];
char link_target[SfileadrL], *rpt; char link_target[SfileadrL], *rpt, **dfilev= NULL;
off_t size; off_t size;
struct stat stbuf; struct stat stbuf;
@ -2019,7 +2081,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, int filec, char **filev,
/* Count valid nodes, warn of invalid ones */ /* Count valid nodes, warn of invalid ones */
for(i= 0; i<filec; i++) { for(i= 0; i<filec; i++) {
ret= Xorriso_make_pattern_adr(xorriso, xorriso->wdi, filev[i], path, 1|4); ret= Xorriso_make_pattern_adr(xorriso, wd, filev[i], path, 1|4);
if(ret<=0) { if(ret<=0) {
was_error++; was_error++;
continue; continue;
@ -2034,20 +2096,51 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, int filec, char **filev,
} }
} }
if(!(flag&(2|4))) { if((flag&8) && !(flag&(2|4))) {
sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec-was_error); sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec-was_error);
Xorriso_info(xorriso,1); Xorriso_info(xorriso,1);
if(filec-was_error<=0) if(filec-was_error<=0)
return(!was_error); return(!was_error);
} }
passes= 1+!(flag&(4|8));
for(pass= 0; pass<passes; pass++)
for(i= 0; i<filec && !(xorriso->request_to_abort); i++) { for(i= 0; i<filec && !(xorriso->request_to_abort); i++) {
rpt[0]= 0; rpt[0]= 0;
ret= Xorriso_make_pattern_adr(xorriso, xorriso->wdi, filev[i], path, 1|4); ret= Xorriso_make_pattern_adr(xorriso, wd, filev[i], path, 1|4);
if(ret<=0) if(ret<=0)
continue; continue;
ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, 0); ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, 0);
if(ret<=0) if(ret<=0)
continue;
if(LIBISO_ISDIR(node) && !(flag&(4|8))) {
if(pass==0)
continue;
if(filec>1) {
strcpy(xorriso->result_line, "\n");
Xorriso_result(xorriso,0);
sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0));
Xorriso_result(xorriso,0);
}
ret= Xorriso_sorted_dir_i(xorriso,
(struct iso_tree_node_dir *) node, &dfilec, &dfilev, boss_mem, 0);
if(ret<=0) {
/* >>> libisofs iterator loop and single item Xorriso_lsx_filev() */;
} else {
if(flag&1) {
sprintf(xorriso->result_line, "total %d\n", dfilec);
Xorriso_result(xorriso,0);
}
Xorriso_ls_filev(xorriso, path,
dfilec, dfilev, boss_mem, (flag&1)|2|8);
}
if(dfilec>0)
Sfile_destroy_argv(&dfilec, &dfilev, 0);
continue;
} else
if(pass>0)
continue; continue;
link_target[0]= 0; link_target[0]= 0;
if((flag&5)==1) { /* -ls_l */ if((flag&5)==1) { /* -ls_l */

View File

@ -68,9 +68,13 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag);
int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter,
char *path, int flag); char *path, int flag);
/* @param flag bit0= long format */ /* @param flag bit0= long format
int Xorriso_ls_filev(struct XorrisO *xorriso, int filec, char **filev, bit1= do not print count of nodes
off_t boss_mem, int flag); bit2= du format
bit3= print directories as themselves (ls -d)
*/
int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
int filec, char **filev, off_t boss_mem, int flag);
/* This function needs less buffer memory than Xorriso_ls_filev() but cannot /* This function needs less buffer memory than Xorriso_ls_filev() but cannot
perform structured pattern matching. perform structured pattern matching.