|
|
|
@ -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 && i<filec; ) {
|
|
|
|
|
npt= (char *) iso_tree_node_get_name(node);
|
|
|
|
|
|
|
|
|
|
ret= Xorriso_regexec(xorriso, npt, &failed_at, 0);
|
|
|
|
|
if(ret)
|
|
|
|
|
continue; /* no match */
|
|
|
|
|
|
|
|
|
|
node_array[i++]= node;
|
|
|
|
|
mem= (filec+1)*sizeof(struct iso_tree_node *);
|
|
|
|
|
Sfile_scale((double) mem, mem_text,5,1e4,0);
|
|
|
|
|
sprintf(xorriso->info_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 && i<filec; ) {
|
|
|
|
|
npt= (char *) iso_tree_node_get_name(node);
|
|
|
|
|
if(!(flag&4)) {
|
|
|
|
|
ret= Xorriso_regexec(xorriso, npt, &failed_at, 0);
|
|
|
|
|
if(ret)
|
|
|
|
|
continue; /* no match */
|
|
|
|
|
}
|
|
|
|
|
node_array[i++]= node;
|
|
|
|
|
}
|
|
|
|
|
filec= i;
|
|
|
|
|
if(filec<=0)
|
|
|
|
|
{ret= 1; goto ex;}
|
|
|
|
|
qsort(node_array, filec, sizeof(struct iso_tree *), Xorriso__node_name_cmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i= 0; i<filec; i++) {
|
|
|
|
|
node= node_array[i];
|
|
|
|
|
if(no_sort) {
|
|
|
|
|
node= iso_tree_iter_next(iter);
|
|
|
|
|
if(node==NULL)
|
|
|
|
|
break;
|
|
|
|
|
npt= (char *) iso_tree_node_get_name(node);
|
|
|
|
|
if(!(flag&4)) {
|
|
|
|
|
ret= Xorriso_regexec(xorriso, npt, &failed_at, 0);
|
|
|
|
|
if(ret)
|
|
|
|
|
continue; /* no match */
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
node= node_array[i];
|
|
|
|
|
|
|
|
|
|
npt= (char *) iso_tree_node_get_name(node);
|
|
|
|
|
rpt[0]= 0;
|
|
|
|
|
|
|
|
|
@ -1516,8 +1547,6 @@ ex:;
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* Xorriso_lsi_outdated_unstructured_patterN */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
|
|
|
|
|
{
|
|
|
|
@ -1856,7 +1885,7 @@ cannot_compile:;
|
|
|
|
|
sprintf(xorriso->info_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)",
|
|
|
|
|