diff --git a/libisoburn/trunk/test/xorriso.c b/libisoburn/trunk/test/xorriso.c index 7e1d64c0..16417760 100644 --- a/libisoburn/trunk/test/xorriso.c +++ b/libisoburn/trunk/test/xorriso.c @@ -4068,16 +4068,17 @@ no_memory:; } if(flag&2) { ret= Xorriso_ls_filev(xorriso, nump, argv + (*idx), flag&1); - if(ret<=0) - {ret= 0; goto ex;} + } else if(nump==1 && strcmp(patterns[0],"*")==0){ + /* save temporary memory by calling simpler function */ + ret= Xorriso_ls(xorriso, (flag&1)|4); } else { ret= Xorriso_expand_pattern(xorriso, nump, patterns, &filec, &filev, 0); if(ret<=0) {ret= 0; goto ex;} ret= Xorriso_ls_filev(xorriso, filec, filev, flag&1); - if(ret<=0) - {ret= 0; goto ex;} } + if(ret<=0) + {ret= 0; goto ex;} ret= 1; ex:; diff --git a/libisoburn/trunk/test/xorriso_timestamp.h b/libisoburn/trunk/test/xorriso_timestamp.h index 9765251a..1078806e 100644 --- a/libisoburn/trunk/test/xorriso_timestamp.h +++ b/libisoburn/trunk/test/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2007.10.31.103338" +#define Xorriso_timestamP "2007.10.31.165413" diff --git a/libisoburn/trunk/test/xorrisoburn.c b/libisoburn/trunk/test/xorrisoburn.c index cd663807..0910b67f 100644 --- a/libisoburn/trunk/test/xorrisoburn.c +++ b/libisoburn/trunk/test/xorrisoburn.c @@ -1358,8 +1358,6 @@ much_too_long:; } -#ifdef Xorriso_lsi_outdated_unstructured_patterN - int Xorriso__node_name_cmp(const void *node1, const void *node2) { char *name1, *name2; @@ -1370,17 +1368,22 @@ int Xorriso__node_name_cmp(const void *node1, const void *node2) } -/* @param flag bit0= long format , bit1= only check for directory existence */ +/* This function needs less buffer memory than Xorriso_ls_filev() but cannot + perform structured pattern matching. + @param flag bit0= long format + bit1= only check for directory existence + bit2= do not apply search pattern but accept any file +*/ int Xorriso_ls(struct XorrisO *xorriso, int flag) { - int ret, is_dir= 0, i, filec, failed_at; + int ret, is_dir= 0, i, filec= 0, failed_at, no_sort= 0; struct iso_tree_node *node, **node_array= NULL; struct iso_tree_node_dir *dir_node; struct iso_volume *volume; struct iso_tree_iter *iter= NULL; - char sfe[4*SfileadrL], *npt, *rpt, perms[10]; + char sfe[4*SfileadrL], *npt, *rpt, perms[10], mem_text[80], limit_text[80]; mode_t st_mode; - off_t size; + off_t size, mem= 0; time_t mtime; struct tm tms, *tmpt; static char months[12][4]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -1413,46 +1416,74 @@ wdi_is_not_a_dir:; for(i= 0; (node= iso_tree_iter_next(iter)) != NULL; ) { npt= (char *) iso_tree_node_get_name(node); - - ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); - if(ret) + if(!(flag&4)) { + ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); + if(ret) continue; /* no match */ - + } filec++; } + /* Reset iteration */ iso_tree_iter_free(iter); iter= NULL; - Xorriso_process_msg_queues(xorriso,0); - node_array= calloc(sizeof(struct iso_tree *), filec+1); - if(node_array==NULL) { - sprintf(xorriso->info_text, - "Cannot allocate memory for %d directory entries", filec); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - ret= -1; goto ex; - } - iter= iso_tree_node_children(dir_node); Xorriso_process_msg_queues(xorriso,0); - for(i= 0; (node= iso_tree_iter_next(iter)) != NULL && iinfo_text, + "Temporary memory needed for result sorting : %s", mem_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + if(mem > xorriso->temp_mem_limit) { + Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1); + sprintf(xorriso->info_text, + "Cannot sort. List of matching files exceeds -temp_mem_limit (%s > %s)", + mem_text, limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + no_sort= 1; } - iso_tree_iter_free(iter); - iter= NULL; - Xorriso_process_msg_queues(xorriso,0); - filec= i; - if(filec<=0) - {ret= 1; goto ex;} - qsort(node_array, filec, sizeof(struct iso_tree *), Xorriso__node_name_cmp); + sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec); + Xorriso_info(xorriso,0); + + if(!no_sort) { + node_array= calloc(sizeof(struct iso_tree_node *), filec+1); + if(node_array==NULL) { + sprintf(xorriso->info_text, + "Cannot allocate memory for %d directory entries", filec); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } + + for(i= 0; (node= iso_tree_iter_next(iter)) != NULL && iinfo_text, "Temporary memory needed for pattern expansion : %s", mem_text); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); - if(count*sizeof(char *)+mem > xorriso->temp_mem_limit) { + if(mem > xorriso->temp_mem_limit) { Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1); sprintf(xorriso->info_text, "List of matching file addresses exceeds -temp_mem_limit (%s > %s)", diff --git a/libisoburn/trunk/test/xorrisoburn.h b/libisoburn/trunk/test/xorrisoburn.h index 2e3c5047..a394de78 100644 --- a/libisoburn/trunk/test/xorrisoburn.h +++ b/libisoburn/trunk/test/xorrisoburn.h @@ -59,6 +59,14 @@ int Xorriso_rmi(struct XorrisO *xorriso, char *path, int flag); int Xorriso_ls_filev(struct XorrisO *xorriso, int filec, char **filev, int flag); +/* This function needs less buffer memory than Xorriso_ls_filev() but cannot + perform structured pattern matching. + @param flag bit0= long format + bit1= only check for directory existence + bit2= do not apply search pattern but accept any file +*/ +int Xorriso_ls(struct XorrisO *xorriso, int flag); + /* @param eff_path returns resulting effective path. Must provide at least SfileadrL bytes of storage. @param flag bit0= do not produce problem events (unless faulty path format)