Changed options -ls* to -lsd*, introduced new family of -ls* without d
This commit is contained in:
@ -1704,9 +1704,10 @@ dir_not_removed:;
|
||||
|
||||
while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4)))
|
||||
&& !xorriso->request_not_to_ask) {
|
||||
Xorriso_ls_filev(xorriso, 1, &path, (off_t) 0, 1|2); /* ls -l */
|
||||
if(is_dir)
|
||||
Xorriso_ls_filev(xorriso, 1, &path, (off_t) 0, 2|4); /* du -s */
|
||||
/* ls -ld */
|
||||
Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 1|2|8);
|
||||
if(is_dir) /* du -s */
|
||||
Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 2|4);
|
||||
if(flag&8)
|
||||
sprintf(xorriso->info_text,
|
||||
"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
|
||||
bit1= do not print count of nodes
|
||||
bit2= du format
|
||||
bit3= print directories as themselves (ls -d)
|
||||
*/
|
||||
int Xorriso_ls_filev(struct XorrisO *xorriso, int filec, char **filev,
|
||||
off_t boss_mem, int flag)
|
||||
int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
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_volume *volume;
|
||||
char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL];
|
||||
char link_target[SfileadrL], *rpt;
|
||||
char link_target[SfileadrL], *rpt, **dfilev= NULL;
|
||||
off_t size;
|
||||
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 */
|
||||
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) {
|
||||
was_error++;
|
||||
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);
|
||||
Xorriso_info(xorriso,1);
|
||||
if(filec-was_error<=0)
|
||||
return(!was_error);
|
||||
}
|
||||
|
||||
passes= 1+!(flag&(4|8));
|
||||
for(pass= 0; pass<passes; pass++)
|
||||
for(i= 0; i<filec && !(xorriso->request_to_abort); i++) {
|
||||
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)
|
||||
continue;
|
||||
ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, 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;
|
||||
link_target[0]= 0;
|
||||
if((flag&5)==1) { /* -ls_l */
|
||||
|
Reference in New Issue
Block a user